I'll explain my situation. so this is a Round script or intermission script you'll notice that when looking at my script below,so when you join a game and the first round start, its fine,but on the second round this is where everything will break.
for i = GameTime, 0, -1 do
if game.Workspace.Felipe:WaitForChild("humanoid").Health == 0 then
print("STOP")
break
elseif game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0 then
print("COUNT")
ChangeText('GameTime ' ..i)
wait(1)
end
end
this is where the error is found,the error only shows when on the second round. is there something im missing? cause im confused af. please help!
--math.randomseed(os.time())
--// Tables
Winners = {}
--// Modules
Settings = require(script.Settings)
--// Game Variables
Intermission = Settings.Intermission
GameTime = Settings.GameTime
--// Functions
function NightTIME()
game.Lighting.FogEnd = 200
local Sky = game.ReplicatedStorage.Sky:Clone()
Sky.Parent = game.Lighting
end
function DayTIME()
game.Lighting.FogEnd = 1000000000
local Sky = game.ReplicatedStorage.DaySky:Clone()
Sky.Parent = game.Lighting
end
function GameWait(Time)
if Time > 0 then
wait(Time)
else
return
end
end
function back()
if game.Workspace.Felipe.humanoid.Health == 0 then
return
end
end
function ChangeText(Text)
local Players = game.Players:GetPlayers()
for i = 1, #Players do
Players[i].PlayerGui:WaitForChild("Main").Time.Text = Text
end
end
--// Game
while true do
local GameSettings = math.random(1,2)
for i = Intermission, 0, -1 do
ChangeText('Intermission ' ..i)
wait(1)
end
local Players = game.Players:GetPlayers()
for i = 1, #Players do
Players[i].PlayerGui.SpectateGui.Enabled = false
Players[i].Playing.Value = true
end
ChangeText('Game starting...')
if GameSettings == 1 then
DayTIME()
elseif GameSettings == 2 then
NightTIME()
end
wait(2)
local Players = game.Players:GetPlayers()
game.Workspace.GameProg.Value = true
for i = 1, #Players do
if Players[i].Playing.Value == true and Players[i].isAFK.Value == false then
Players[i].Character.Torso.CFrame = game.Workspace.TP.CFrame
Players[i].Character.Humanoid.WalkSpeed = 0
end
end
for i = 5, 0, -1 do
ChangeText('Starting in ' ..i)
wait(1)
end
local Players = game.Players:GetPlayers()
for i = 1, #Players do
if Players[i].Playing.Value == true then
if Players[i].CurrentGun.Value == "Glock" then
local Weapon = game.ReplicatedStorage.Glock
Weapon:Clone().Parent = Players[i].Backpack
elseif Players[i].CurrentGun.Value == "AWM" then
local Awm = game.ReplicatedStorage.Awm
Awm:Clone().Parent = Players[i].Backpack
elseif Players[i].CurrentGun.Value == "M4A1" then
print("GiveM4a1")
end
Players[i].Character.Humanoid.WalkSpeed = 16
end
end
ChangeText('BEGIN!')
--or game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0
for i = GameTime, 0, -1 do
if game.Workspace.Felipe:WaitForChild("humanoid").Health == 0 then
print("STOP")
break
elseif game.Workspace.Felipe:WaitForChild("humanoid").Health ~= 0 then
print("COUNT")
ChangeText('GameTime ' ..i)
wait(1)
end
end
-- Awarding players
local Players = game.Players:GetPlayers()
for i = 1, #Players do
if Players[i].Playing.Value == true then
table.insert(Winners, Players[i].Name)
Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 10
Players[i].leaderstats.Wins.Value = Players[i].leaderstats.Wins.Value + 0.5
Players[i].Character.Humanoid.Health = 0
Players[i].Playing.Value = false
end
end
if GameSettings == 1 then
game.Lighting:FindFirstChild("DaySky"):Destroy()
elseif GameSettings == 2 then
game.Lighting:FindFirstChild("Sky"):Destroy()
game.Lighting.FogEnd = 1000000000
end
for i,v in pairs(game.Workspace.MinionsFOLD:GetChildren()) do
v:Destroy()
end
game.Workspace.GameProg.Value = false
ChangeText('GAME OVER!')
wait(4)
end
--//why am i doing this crap

5 comments
there's a respawn script on the npc
try capitalizing the h in humanoid
the npc's Humanoid name is humanoid so no point of that i guess?
After the First Round, check to make sure that the players are still in game.Workspace.Felipe? That might be why?
It's "Humanoid". For the future, when it does "Infinite yield possible on...", that may mean that the instance cannot be found.