I made a script for my friend's obby based game , everything works fine but when the countdown is over there is no counter for time limit and whenever i reset it doesnt tp me back did i do something wrong? heres the script

local players = game:GetService("Players"):GetPlayers()
local RealPlayers = #players
v:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = false
game.Workspace.Sound:Pause()
game.ServerStorage["Poison Forest"].Parent = game.Workspace
v.Character.HumanoidRootPart.CFrame = game.Workspace["Poison Forest"].Map2.CFrame * CFrame.new(0,3,0)
v.Character.HumanoidRootPart.Anchored = true
v.InGame.Value = 1
RealPlayers = RealPlayers - 1
while true do wait (0.1)
if RealPlayers == 0 then

game.Workspace.CountDown:Play()
v:WaitForChild("PlayerGui").CountDown.Frame.Visible = true 
v:WaitForChild("PlayerGui").CountDown.Frame.TextLabel.Text = "3" wait (1)
v:WaitForChild("PlayerGui").CountDown.Frame.TextLabel.Text = "2" wait (1)
v:WaitForChild("PlayerGui").CountDown.Frame.TextLabel.Text = "1" wait (1)
v:WaitForChild("PlayerGui").CountDown.Frame.Visible = false


game.Workspace.CountDown:Stop()
v.Character.HumanoidRootPart.Anchored = false

wait (0.1)
game.Workspace.PoisonForest:Play()
break
end
local players = game:GetService("Players"):GetPlayers()
local Dudes = #players
v.Character.Humanoid.Died:connect(function()
if v.InGame.Value == 1 then
v.InGame.Value = 0
Dudes = Dudes - 1
end
end)
while true do wait (1)
local I = 120
local Hint = Instance.new("Hint")
Hint.Parent = game.Workspace
Hint.Name = "Counter"
I = I - 1
Hint.Text = "Time Left: "..I
if I == 0 or Dudes == 0 or v.Complete.Value == 1 then
for _, I in pairs(game.Players:GetChildren()) do
if I.Character.Humanoid.Health > 0 then
local Root = I.Character.HumanoidRootPart
Root.CFrame = game.Workspace.Lobby.Spawn.CFrame * CFrame.new(0,3,0)
end

i would give the full script but it is way to long and a mod wil just remove my post

5 comments

0

didn't you forget the "for i, v in pairs" loop at start? From where did u got "v"?

0

i do have it at the very start of the script

0

i cant give the full script because my post will get moderated

0

but can u explain why the current script doesnt work?

0

also yes there is a break near the end of the script