generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Function Is Nil Value?

Previous Thread :: Next Thread 
Hibobb is not online. 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 is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
22 Dec 2014 07:41 PM
B
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
22 Dec 2014 07:41 PM
You probably spelled something wrong
Report Abuse
DavidBene is not online. 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 is not online. 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 is not online. 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 is not online. DavidBene
Joined: 26 Nov 2014
Total Posts: 163
22 Dec 2014 07:57 PM
Oh and do the same with:

PlayerStuff(players)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image