Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gameLength = 120
- game.Players.PlayerAdded:Connect(function(plr)
- local ls = Instance.new("Folder", plr)
- ls.Name = "leaderstats"
- local cash = Instance.new("IntValue", ls)
- cash.Name = "Cash"
- end)
- local playersAlive = {}
- local playersCompleted = {}
- local redLight = false
- game:GetService("RunService").Heartbeat:Connect(function()
- for i, player in pairs(game.Players:GetPlayers()) do
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- if player.Character.Humanoid.MoveDirection.Magnitude > 0 and redLight and table.find(playersAlive, player) then
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- end
- end
- end
- end)
- while true do
- wait(1)
- workspace.SquidGame.PreGameBarrier.CanCollide = true
- workspace.SquidGame.EndGameBarrier.CanCollide = false
- workspace.SquidGame.Doll.Head.Orientation = Vector3.new(0, 0, 0)
- for i, player in pairs(game.Players:GetPlayers()) do
- player:LoadCharacter()
- table.insert(playersAlive, player)
- player.Character.Humanoid.Died:Connect(function()
- table.remove(playersAlive, table.find(playersAlive, player))
- end)
- end
- game.ReplicatedStorage.SquidGameRE:FireAllClients("status", "Game starting..", Color3.fromRGB(255, 255, 255))
- wait(3)
- workspace.SquidGame.PreGameBarrier.CanCollide = false
- local timeLeft = gameLength
- spawn(function()
- while timeLeft > 0 and #playersAlive > 0 do
- timeLeft -= 1
- local mins = math.floor(timeLeft / 60)
- local secs = timeLeft % 60
- if string.len(mins) < 2 then mins = "0" .. mins end
- if string.len(secs) < 2 then secs = "0" .. secs end
- game.ReplicatedStorage.SquidGameRE:FireAllClients("timer", mins .. ":" .. secs)
- wait(1)
- end
- end)
- workspace.SquidGame.EndGameBarrier.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- table.remove(playersAlive, table.find(playersAlive, player))
- table.insert(playersCompleted, player)
- game.ReplicatedStorage.SquidGameRE:FireClient(player, "barrier", workspace.SquidGame.EndGameBarrier)
- end
- end)
- while timeLeft > 0 and #playersAlive > 0 do
- game.ReplicatedStorage.SquidGameRE:FireAllClients("status", "GREEN LIGHT", Color3.fromRGB(0, 255, 0))
- local randomSpeed = math.random(8, 13)/10
- script.Sound.PlaybackSpeed = randomSpeed
- script.Sound:Play()
- script.Sound.Ended:Wait()
- game:GetService("TweenService"):Create(workspace.SquidGame.Doll.Head, TweenInfo.new(0.3), {Orientation = Vector3.new(0, 180, 0)}):Play()
- redLight = true
- game.ReplicatedStorage.SquidGameRE:FireAllClients("status", "RED LIGHT", Color3.fromRGB(255, 0, 0))
- wait(math.random(1, 5))
- game:GetService("TweenService"):Create(workspace.SquidGame.Doll.Head, TweenInfo.new(0.3), {Orientation = Vector3.new(0, 0, 0)}):Play()
- redLight = false
- end
- for i, player in pairs(playersAlive) do
- player.Health = 0
- script.Shot:Play()
- end
- for i, player in pairs(playersCompleted) do
- player.leaderstats.Cash.Value += math.floor(10000 / #playersCompleted)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement