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
- local cookieGame = false
- local playerCookieCracks = {}
- local playerMouses = {}
- game.ReplicatedStorage.SquidGameRE.OnServerEvent:Connect(function(player, mouseStatus, mouseCF)
- if mouseStatus then
- playerMouses[player] = mouseCF
- else
- playerMouses[player] = nil
- end
- end)
- 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.HumanoidRootPart.Velocity.Magnitude > 0 and redLight and table.find(playersAlive, player) then
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- elseif cookieGame then
- if playerMouses[player] and script.Parent.Honeycomb.Cookies:FindFirstChild(player.Name .. "Cookie") then
- local cookie = script.Parent.Honeycomb.Cookies[player.Name .. "Cookie"]
- local nextPiece = nil
- for i = 1, #cookie.Shape:GetChildren() do
- if cookie.Shape[i].Color == Color3.fromRGB(27, 42, 53) then
- nextPiece = cookie.Shape[i]
- break
- end
- end
- if nextPiece and playerMouses[player] == nextPiece then
- nextPiece.Color = Color3.fromRGB(62, 223, 17)
- elseif playerMouses[player].Parent ~= script.Parent.Honeycomb.Cookies[player.Name .. "Cookie"].Shape and not playerCookieCracks[player] then
- playerCookieCracks[player] = true
- game.ReplicatedStorage.HoneycombCrackDecal:Clone().Parent = script.Parent.Honeycomb.Cookies[player.Name .. "Cookie"].Cookie
- script.Crack:Play()
- wait(3)
- playerCookieCracks[player] = false
- elseif not nextPiece then
- table.remove(playersAlive, table.find(playersAlive, player))
- table.insert(playersCompleted, player)
- script.Parent.Honeycomb.Cookies[player.Name .. "Cookie"]:Destroy()
- player.Character.HumanoidRootPart.Anchored = false
- end
- end
- end
- end
- end
- end)
- while true do
- wait(3)
- playersAlive = {}
- playersCompleted = {}
- script.Parent.Honeycomb.PlayerCells:ClearAllChildren()
- script.Parent.RedLightGreenLight.PreGameBarrier.CanCollide = true
- script.Parent.RedLightGreenLight.EndGameBarrier.CanCollide = false
- script.Parent.RedLightGreenLight.Doll.Head.Orientation = Vector3.new(0, 0, 0)
- for i, player in pairs(game.Players:GetPlayers()) do
- player:LoadCharacter()
- player.Character.HumanoidRootPart.CFrame = script.Parent.RedLightGreenLight.SpawnPart.CFrame
- 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)
- --Red Light Green Light Game
- script.Parent.RedLightGreenLight.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)
- script.Parent.RedLightGreenLight.EndGameBarrier.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if table.find(playersAlive, player) then
- table.remove(playersAlive, table.find(playersAlive, player))
- table.insert(playersCompleted, player)
- game.ReplicatedStorage.SquidGameRE:FireClient(player, "barrier", script.Parent.RedLightGreenLight.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.Song.PlaybackSpeed = randomSpeed
- script.Song:Play()
- script.Song.Ended:Wait()
- game:GetService("TweenService"):Create(script.Parent.RedLightGreenLight.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(script.Parent.RedLightGreenLight.Doll.Head, TweenInfo.new(0.3), {Orientation = Vector3.new(0, 0, 0)}):Play()
- redLight = false
- end
- for i, player in pairs(playersAlive) do
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- end
- wait(5)
- --Honeycomb Game
- playersAlive = playersCompleted
- playersCompleted = {}
- game.ReplicatedStorage.SquidGameRE:FireAllClients("status", "CUT THE COOKIE", Color3.fromRGB(255, 255, 255))
- for i, spawnPart in pairs(script.Parent.Honeycomb.Spawns:GetChildren()) do
- local player = playersAlive[i]
- if player then
- local newBlock = game.ReplicatedStorage.HoneycombTemplate:Clone()
- newBlock:SetPrimaryPartCFrame(spawnPart.CFrame)
- newBlock.Parent = script.Parent.Honeycomb.PlayerCells
- player.Character.HumanoidRootPart.CFrame = newBlock.SpawnPart.CFrame
- wait()
- player.Character.HumanoidRootPart.Anchored = true
- local cookie = game.ReplicatedStorage.HoneycombCookies:GetChildren()[math.random(1, #game.ReplicatedStorage.HoneycombCookies:GetChildren())]:Clone()
- cookie.Name = player.Name .. "Cookie"
- cookie.Parent = script.Parent.Honeycomb.Cookies
- cookie.Shape["1"].Color = Color3.fromRGB(62, 223, 17)
- game.ReplicatedStorage.SquidGameRE:FireClient(player, "honeycomb", cookie)
- cookie.Cookie.ChildAdded:Connect(function()
- if #cookie.Cookie:GetChildren() > 2 then
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- end
- end)
- end
- end
- timeLeft = gameLength
- cookieGame = true
- 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
- script.Parent.Honeycomb.Cookies:ClearAllChildren()
- for i, player in pairs(playersAlive) do
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- end
- game.ReplicatedStorage.SquidGameRE:FireAllClients("honeycombEnd")
- cookieGame = false
- --Glass Tiles Game
- playersAlive = playersCompleted
- playersCompleted = {}
- game.ReplicatedStorage.SquidGameRE:FireAllClients("status", "GLASS TILES", Color3.fromRGB(255, 255, 255))
- for i, player in pairs(playersAlive) do
- player.Character.HumanoidRootPart.CFrame = script.Parent.GlassTiles.SpawnPart.CFrame
- end
- for tileNum = 1, #script.Parent.GlassTiles.TilesLeft:GetChildren() do
- script.Parent.GlassTiles.TilesLeft[tileNum].Transparency, script.Parent.GlassTiles.TilesRight[tileNum].Transparency = 0.4, 0.4
- local num = math.random(0, 1)
- local tile = num == 0 and script.Parent.GlassTiles.TilesLeft[tileNum] or script.Parent.GlassTiles.TilesRight[tileNum]
- tile.CanCollide = false
- tile.Touched:Connect(function()
- tile.Transparency = 1
- end)
- end
- script.Parent.GlassTiles.Floor.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- hit.Parent.Humanoid.Health = 0
- end
- end)
- script.Parent.GlassTiles.End.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if table.find(playersAlive, player) then
- table.remove(playersAlive, table.find(playersAlive, player))
- table.insert(playersCompleted, player)
- wait(1)
- hit.Parent.HumanoidRootPart.Anchored = true
- end
- end)
- timeLeft = gameLength
- 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
- for i, player in pairs(playersAlive) do
- player.Character.Humanoid.Health = 0
- script.Shot:Play()
- end
- --Reward winners
- 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