So I am making a zombie games and I have 3 different maps and I am trying to make the maps randomly spawn but I keep getting an error. Here is the script with the error.
local countdown = game.ReplicatedStorage.Values:WaitForChild(“countdown”)
for i = 15,0,-1 do
countdown.Value = i
if 1 then
local map = math.random(1,3)
if map == 1 then
game.ReplicatedStorage.Maps[“Nuketown Zombies”]:Clone().Parent = workspace.Map
end
if map == 2 then
game.ReplicatedStorage.Maps[“Rundown hosipital area”]:Clone().Parent = workspace.Map
end
if map == 3 then
game.ReplicatedStorage.Maps[“Town Map”]:Clone().Parent = workspace.Map
end
print(map)
for i, v in pairs(game.Players:GetPlayers()) do
v.Character.UpperTorso.CFrame = workspace.Map:FindFirstChildOfClass(“Model”).Spawn.CFrame
end
end
wait(1)
end
And the error
18:09:11.869 2 - Server - Script:16
18:09:11.870 ServerScriptService.Script:18: attempt to index nil with ‘UpperTorso’ - Server - Script:18
18:09:11.870 Stack Begin - Studio
18:09:11.870 Script ‘ServerScriptService.Script’, Line 18 - Studio - Script:18
18:09:11.870 Stack End
18:38:27.193 3 - Server - Script:16
18:38:27.193 ServerScriptService.Script:18: attempt to index nil with ‘WaitForChild’ - Server - Script:18
18:38:27.193 Stack Begin - Studio
18:38:27.193 Script ‘ServerScriptService.Script’, Line 18 - Studio - Script:18
18:38:27.194 Stack End
Now it errored how it did at the beginning
18:41:13.529 2 - Server - Script:16
18:41:13.530 ServerScriptService.Script:18: attempt to index nil with ‘UpperTorso’ - Server - Script:18
18:41:13.530 Stack Begin - Studio
18:41:13.530 Script ‘ServerScriptService.Script’, Line 18 - Studio - Script:18
18:41:13.530 Stack End
for i, v in pairs(game.Players:GetPlayers()) do
v.Character.UpperTorso.CFrame = workspace.Map:FindFirstChildOfClass("Model").Spawn.CFrame
if not v.Character then return
end
end
end
wait(1)
Wait Its no longer working it worked once
Its erroring again
18:54:15.811 ServerScriptService.Script:19: attempt to index nil with ‘UpperTorso’ - Server - Script:19
18:54:15.811 Stack Begin - Studio
18:54:15.811 Script ‘ServerScriptService.Script’, Line 19 - Studio - Script:19
18:54:15.812 Stack End
What do I do about this 19:08:33.019 Infinite yield possible on ‘Workspace.baseballcal15:WaitForChild(“HumanoidRootPart”)’ - Studio
19:08:33.019 Stack Begin - Studio
19:08:33.019 Script ‘ServerScriptService.Script’, Line 19 - Studio - Script:19
19:08:33.019 Stack End
To my knowledge the first issue should not be an error but just a warning. This should be fine but you can always add a timeout to make sure it doesn’t hold up the entire script forever, just add a comma followed by how long you want to wait. (You can read about it here Instance | Documentation - Roblox Creator Hub)
As for the glitching, I have no clue. Is it just happening in studio or also in the actual Roblox player? You can check if your fps is running at 60 by doing ctrl+shift+f5.