Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 22 Dec 2014 07:22 PM |
When I try to call a function in my script it gives this error message: 20:21:58.694 - Workspace.MyMaze:10: attempt to call global 'GenerateMaze' (a nil value)
Line 10 is: GenerateMaze()
And the function does exist, function GenerateMaze() |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 22 Dec 2014 07:41 PM |
| You probably spelled something wrong |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 22 Dec 2014 07:43 PM |
Try moving the function GenerateMaze() to the first line and see if that helps.
It could also help if we could see the script itself. |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 22 Dec 2014 07:46 PM |
The script is about 1000 lines so thats unlikely. Here is the main part. Both PlayerStuff(players) or GenerateMaze() return the above message when called:
wait() spawns = {}
while wait() do players = game.Players:GetPlayers() if #players > 0 then for _,v in pairs(players) do game.Lighting.ScreenGui:Clone().Parent = v.PlayerGui end GenerateMaze() PlayerStuff(players) repeat wait() until script.EndGame.Value == true for _,v in pairs(players) do local spawns = {} for _,v in pairs(workspace.Lobby:GetChildren()) do if v.Name == "SpawnLocation" then table.insert(spawns,v) end end if v.Character then v.Character:MoveTo(spawns[math.random(1,#spawns)].Position) end end for _,v in pairs(workspace:GetChildren()) do if v.Name ~= "Lobby" and v.Name ~= "Camera" and v ~= script then local hum = v:FindFirstChild("Humanoid") if not hum then v:Destroy() end end end end end |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 22 Dec 2014 07:56 PM |
Well I did a quick test with my own GenerateMaze() function.
You need to put the GenerateMaze() code above the code you currently have so you can define it before the loop starts. It returns the error when it's defined after the while loop.
So put it like this:
function GenerateMaze() print("Test") end
while wait() do players = game.Players:GetPlayers() if #players > 0 then for _,v in pairs(players) do game.Lighting.ScreenGui:Clone().Parent = v.PlayerGui end GenerateMaze() repeat wait() until script.EndGame.Value == true for _,v in pairs(players) do local spawns = {} for _,v in pairs(workspace.Lobby:GetChildren()) do if v.Name == "SpawnLocation" then table.insert(spawns,v) end end if v.Character then v.Character:MoveTo(spawns[math.random(1,#spawns)].Position) end end for _,v in pairs(workspace:GetChildren()) do if v.Name ~= "Lobby" and v.Name ~= "Camera" and v ~= script then local hum = v:FindFirstChild("Humanoid") if not hum then v:Destroy() end end end end end |
|
|
| Report Abuse |
|
|
DavidBene
|
  |
| Joined: 26 Nov 2014 |
| Total Posts: 163 |
|
|
| 22 Dec 2014 07:57 PM |
Oh and do the same with:
PlayerStuff(players) |
|
|
| Report Abuse |
|
|