Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ummm my script keeps teleporting me constantly each time only when it is intermission?

Please help me I cant figure it out.

local roundLength = 120
local intermissionLength = 15
local Status = game.ReplicatedStorage.Status
local inRound = game.ReplicatedStorage.InRound
local Lobby = game.Workspace.Lobby
local Roundspawn = game.Workspace.Maps["Science Lab"].ScienceLabsSpawns.ScienceLabSpawn


inRound.Changed:Connect(function()
	wait(1)
	if inRound.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char  = player.Character
			char.HumanoidRootPart.CFrame = Roundspawn.CFrame
		end	

	else
		wait(1)
		for _, player in pairs(game.Players:GetChildren()) do
			local char  = player.Character
			char.HumanoidRootPart.CFrame = Lobby.CFrame
		end

	end

end)




local function roundTimer()
	while wait() do
		for i = intermissionLength, 1, -1 do
			inRound.Value = false
			wait(1)
			Status.Value = "intermission: ".. i .." seconds left!"
		end
		for i = roundLength, 1, -1 do
			inRound.Value = true
			wait(1)
			Status.Value = "Game: ".. i .." seconds left"
		end
	end	
end

spawn(roundTimer)



1 comment

0

Use GetPropertyChangedSignal() instead of Changed. Changed event checks for ANY changes.

1 answer

You see, the "inRound" value is never false, which is why it keeps on constantly teleporting you.

Fix it by adding

inRound.Value == false

under if inRound.Value == true then

then when your round ends, add

inRound.Value == true

to where the round ends to restart the loop

This discussion is preserved as it was. New answers, comments, and votes are closed.