ajloni
|
  |
| Joined: 30 Aug 2015 |
| Total Posts: 108 |
|
|
| 19 Dec 2016 08:46 PM |
I am making a script for my round based game, and it chooses rounds and it teleports players to the round, but every time I run it I get this error. "21:44:44.784 - Workspace.Script:24: attempt to index field '?' (a nil value)" Please help! Here is my code.
----------------------------------------------------------------------------------------------------
local h = Instance.new("StringValue",game.ReplicatedStorage) h.Name = "MapChanged" local maps = game.Lighting.Maps:GetChildren() while true do if game.Players.NumPlayers >= 0 then h.Value = "Choosing Map..." wait(3)
local randomMap = math.random(1, #maps) local mapChosen = maps[randomMap] local mapChosen = maps[randomMap] h.Value = "Map Chosen: " ..mapChosen.Name wait(3) local mapChosenClone = mapChosen:Clone() mapChosenClone.Parent = game.Workspace --teleporting the players local spawns = mapChosenClone.SpawnLocation:GetChildren() for i, v in pairs(game.Players:GetPlayers()) do local name = v.Name local check = game.Workspace:FindFirstChild(name) if check then local humanoid = check:FindFirstChild("Humanoid") if humanoid then check:MoveTo(spawns[i].Position) end end end
for i = 70, 1, -1 do h.Value = "Tsunami in progress!"
wait(1) end h.Value = "Game ended!" wait(3) mapChosenClone:Destroy() else h.Value = "ERROR" end wait(.1) end
--------------------------------------------------------------------------------------------------
Please put suggestions in the replies section. Thanks! |
|
|
| Report Abuse |
|