I’m making a game in wich a player is selected to do a wipeout obby, and he has 3 minutes to make it. I’m trying to make a touch event that when the player gets to the end, the script restarts, but even when no is touching it, it restarts, breaking the game. Here’s the part of the code:
repeat
workspace.Time.Value = workspace.Time.Value - 1
wait(1)
until workspace.Time.Value==0 or workspace.map.Win.WinPart2.Touched
if workspace.Time.Value==0 then
workspace.map.Win.WinPart2:Destroy()
workspace.map.Win.Winpart3.Position = Vector3.new(1025.471, 94.3, -23161.836)
workspace.Time.Value = 240
workspace.Fail:Play()
local Hint = Instance.new("Message")
Hint.Parent = workspace
Hint.Text = "Time's up!"
wait(2.5)
Hint:Destroy()
wait(6.1)
tp2()
elseif workspace.map.Win.WinPart2.Touched and workspace.Time.Value>0 then
workspace.map.Win.WinPart2:Destroy()
workspace.map.Win.Winpart3.Position = Vector3.new(1025.471, 94.3, -23161.836)
workspace.Time.Value = 240
workspace.Victory:Play()
local Hint = Instance.new("Message")
Hint.Parent = workspace
Hint.Text = "The player made it!"
wait(2.5)
Hint:Destroy()
wait(6.1)
tp2()
end
end
I don’t even know where’s the problem in the script, it should only activate when a player touches it.