I am making a Hide and Seek game. I am doing the gameplay scripting, but my game won't even run the first section of my script! I added a print to test if it got that far, it does not. I realize it is most likely an easy fix, but I cannot find it.
local roundtimer = 60 * 3 local intermissiontime = 5 local serverstorage = game:GetService("ServerStorage") local replicatedstorage = game:GetService("ReplicatedStorage") local debris = game:GetService("Debris") local event = replicatedstorage:WaitForChild("RemoteEvent") local maps = serverstorage:WaitForChild("Maps") local mapholder = game.Workspace:WaitForChild("MapHolder") while true do print("we made it") --Wait for contestants while true do wait(1) contestants = {} for _, player in pairs(game.Players:GetPlayers()) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end end if #contestants >= 2 then print("we have enough") break end --Load a random map mapholder:ClearAllChildren() wait(2) local allmaps = maps:GetChildren() local newmap = allmaps[math.random(1, #allmaps)] newmap.Parent = game.Workspace print(newmap.Name) wait(2)
I am not getting anything in the output from my prints, but I am getting this error twice:
22:16:07.567 - Replication: Can't create default object of type Workspace
and I am also getting this in red:
(a huge link with personal data): WinHttpReceiveResponse, err=0x2EE2
Thanks in advance.
****UPDATE**
I changed up the variables, I think that was the issue. But now I am getting stuck when checking for enough players to play.
local roundtimer = 60 * 3 local intermissiontime = 5 local serverstorage = game.ServerStorage local replicatedstorage = game.ReplicatedStorage --local debris = game:GetService("Debris") I'm not using this so I hinted it --local event = replicatedstorage.RemoteEvent I'm not using this so I hinted it local maps = game.ServerStorage.Maps local mapholder = game.Workspace.MapHolder while true do print("here") -- this prints --Load a random map mapholder:ClearAllChildren() wait(2) local allmaps = maps:GetChildren() local newmap = allmaps[math.random(1, #allmaps)]:clone() newmap.Parent = game.Workspace print(newmap.Name) -- this prints wait(2) --Wait for contestants while true do print("this works") -- this prints over and over again even though I am using the Test feature with two players wait(1) contestants = {} for _, player in pairs(game.Players:GetPlayers()) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end end if #contestants >= 2 then print("we have enough") -- this does not print break end
Are you sure that line 01 - 08 are all executed. It seems that the Script is waiting for the children.
Also to fix your double while true do loop Remove line 14 - 22 and do
local People = {} for _,v in pairs(Game:GetService('Players'):GetChildren()) do if type(v.Character) ~= nil then if v.Character.Humanoid.Health > 0 then table.insert(People, v) end end end
Other errors : - Please be aware that the contestants = {} variable needs to be moved out of the while true do scoop (Second one) to actually use it later on