I made this script for my friend's game which is a obby based game, But the problem is that everything works fine but when you actully start the obby the countdown doesnt appear and when u die it doesnt tp u back and give the text, and there is no error in /console, So can u please explain whats wrong with the script?
function EventA() -- this is a example of a event, This will be done if the math.random gets this event. the text is made by a variable, You can edit it for ur own text
for _, v in pairs(game.Players:GetChildren()) do
v.Complete.Value = 0
v:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
local msg = "Welcome to the Purple Forest Obby made by RainbowFire66 "
local text = msg
local Texty = v:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel
for i = 1,#text do
Texty.Text = string.sub(text,1,i)
local cor = coroutine.wrap(function()
local sound = Instance.new("Sound")
sound.Volume = .5
sound.SoundId = "rbxassetid://151715959"
sound.Parent = v:WaitForChild("PlayerGui").ScreenGui
sound:Play()
sound.Ended:Wait()
sound:Destroy()
end)
cor()
wait(0.03)
end
wait (3)
local msg = "You have 2 minute to complete this obby, goodluck."
local text = msg
local Texty = v:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel
for i = 1,#text do
Texty.Text = string.sub(text,1,i)
local cor = coroutine.wrap(function()
local sound = Instance.new("Sound")
sound.Volume = .5
sound.SoundId = "rbxassetid://151715959"
sound.Parent = v:WaitForChild("PlayerGui").ScreenGui
sound:Play()
sound.Ended:Wait()
sound:Destroy()
end)
cor()
wait(0.03)
end
wait (3)
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
if v.Complete.Value == 1 then wait (0.1)
v.Complete.Value = 0
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
game.Workspace.Sound:Resume()
game.Workspace.PoisonForest:Stop()
I:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
I.leaderstats.Money.Value = I.leaderstats.Money.Value + 50
v.leaderstats.Money.Value = v.leaderstats.Money.Value + 150
Hint:Destroy()
local msg = v.Name.." Is the winner of the obby"
local text = msg
local Texty = v:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel
for i = 1,#text do
Texty.Text = string.sub(text,1,i)
local cor = coroutine.wrap(function()
local sound = Instance.new("Sound")
sound.Volume = .5
sound.SoundId = "rbxassetid://151715959"
sound.Parent = v:WaitForChild("PlayerGui").ScreenGui
sound:Play()
sound.Ended:Wait()
sound:Destroy()
end)
cor()
wait(0.03)
end
wait (3)
v:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = false
game.Workspace["Poison Forest"].Parent = game.ServerStorage
-- when event is done it will automatically do intermission
Intermission()
break
end
end
else
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
game.Workspace.Sound:Resume()
game.Workspace.PoisonForest:Stop()
I:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
I.leaderstats.Money.Value = I.leaderstats.Money.Value + 50
Hint:Destroy()
local msg = "Nobody won isn't that a suprise?"
local text = msg
local Texty = v:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel
for i = 1,#text do
Texty.Text = string.sub(text,1,i)
local cor = coroutine.wrap(function()
local sound = Instance.new("Sound")
sound.Volume = .5
sound.SoundId = "rbxassetid://151715959"
sound.Parent = v:WaitForChild("PlayerGui").ScreenGui
sound:Play()
sound.Ended:Wait()
sound:Destroy()
end)
cor()
wait(0.03)
end
end
wait (3)
v:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = false
game.Workspace["Poison Forest"].Parent = game.ServerStorage
Intermission()
break
end
end
end
end
end

2 comments
Could you shorten and simplify the script?
i aint sure thats why i posted it here, becuz it doesnt work and idk whats the error so im afraid to shorten it becuz idk where to shorten it