What is wrong with my script?

local InGame = game.ReplicatedStorage.InGame
local FloorGlass = game.Workspace.GameSpawn.FloorGlass
local gameRoundTimer = 5
local roundLength = 5
local intermissionLength = 10
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local RoundEnd = game.ReplicatedStorage.RoundEnd

local LobbySpawn = game.Workspace.LobbySpawn
local GameAreaSpawn = game.Workspace.GameSpawn.GameAreaSpawn


RoundEnd.Changed:Connect(function()
	if RoundEnd == true then
		Status.Value = "Game Over!"
		
	end
end)


InGame.Changed:Connect(function()
	if InGame.Value == true then
		FloorGlass.Transparency = 1
		FloorGlass.CanCollide = false
		wait(5)
		FloorGlass.Transparency = 0.5
		FloorGlass.CanCollide = true
	end
end)


InRound.Changed:Connect(function()
	if InRound.Value == true then
		for _, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char:WaitForChild("HumanoidRootPart").CFrame = GameAreaSpawn.CFrame * CFrame.new(0,3.25,0)
		end
	else
		for _, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char:WaitForChild("HumanoidRootPart").CFrame = LobbySpawn.CFrame * CFrame.new(0,3.25,0)
		end
	end
end)

local function roundTimer()
	while wait() do
		InRound.Value = false
		for i = intermissionLength, 0, -1 do
			wait(1)
			Status.Value = "Intermission: ".. i .." seconds left!"
			InRound.Value = true
		end
		for i = gameRoundTimer, 0, -1 do
			wait(1)
			Status.Value = "Dropping Players: ".. i .." seconds left!"
			InGame = true
		end
		for i = roundLength, 0, -1 do
			wait(1)
			Status.Value = "Game: ".. i .." seconds left!"
			RoundEnd = true
		end
	end
end

spawn(roundTimer())

Need more information. What is it supposed to do? What does it do?

Not enough info. What’s the problem?

It is supposed make it so when the player joins the game it should start an intermission and then teleport my player to a glass box When the timer for the glass box is done then player drops into the game.

Ok, so what’s wrong with it? Is it like the glass won’t go away when the timer ends or what?

1 Like

It sounds like the Change events aren’t firing. I suggest, since InGame and InRound always happen at specific intervals, don’t use events. Just make them normal functions and call them when you change the game state.

you have to use .value while using value objects to set the value

1 Like