Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why this code keeps error and in the dev console it says : a nil value? [Answered]

Asked by 9 years ago

Im trying to make a minigame that only have 1 map for now and its speed run. The problem is it keeps saying a nil value until I have no idea. So I need a help here. Here is the dev console : [I use a link because I can't put my screenshot here by using trello] https://trello.com/c/owZ7gkSZ/27-a-nil-value-problem-screenshot

And the script :

01--start
02local Player1 = game.Players.PlayerAdded:wait()
03 
04--variables
05Map1 = game.ServerStorage.Maps.Arena1
06NotificationBoard = game.Workspace.StatusBar.Text
07TpEnabled = false
08 
09-- Scripts
10--TpScript
11--Reciver Vars
12Spawn1o = 0
13Spawn2o = 0
14Spawn3o = 0
15Spawn4o = 0
View all 98 lines...
0
Line 2 - It's not gonna work that way, You gotta bind a function to player added event buoyantair 123 — 9y
0
The problem is the line 61. See the dev console screenshot krisxxxz 45 — 9y
0
Anyway thanks for that tips. Because I just noticed that line 2 is a bit weird and glitchy before I edit the script into the script you see now. krisxxxz 45 — 9y

1 answer

Log in to vote
1
Answered by
Scarious 243 Moderation Voter
9 years ago

As I see it, your script is flawed that, even if we do give an answer... it will not work with the rest of your coding... as such, i suggest you try to make it so that everything is coherent... for example:

The map is still in ServerStorage, to move it you should use:

1local mapholder = Instance.new("Model", game.Workspace)
2mapholder.Name = "CurrentMap"
3 
4game.ServerStorage.Maps.Arena --[[ error ]]

Your map will now error because the map has a NumberValue in a line of code that has a String, as such you will need to use FindFirstChild()

1local mapholder = Instance.new("Model", game.Workspace)
2mapholder.Name = "CurrentMap"
3 
4local mapa = game.ServerStorage.Maps:FindFirstChild("Arena1")
5mapa.Parent = mapholder

I could keep going on, but I will instead recommend you to some ROBLOX wiki pages that you should learn:

http://wiki.roblox.com/index.php?title=Loops

http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions&redirect=no#pairs

http://wiki.roblox.com/index.php?title=API:Class/Instance/FindFirstChild

After you have done this, you should start from scratch, and attempt to create a smooth code.. if you still cannot do this, pm me on roblox (Username: Taryo)

~ Taryo

Edit:

Removed CFrame and Vector3 from recommended list, you can still view them here:

http://wiki.roblox.com/index.php?title=CFrame http://wiki.roblox.com/index.php?title=Vector3

0
Thanks alot for the help. krisxxxz 45 — 9y
0
You're welcome... The issue was that even though some of your code worked... it wouldn't work with the rest of your code. I recommended you to some places, but also make sure to review functions here: http://wiki.roblox.com/index.php?title=Function Scarious 243 — 9y
0
And why do you give me about CFrames and vector 3? Is it about the teleporter? The teleporter doesn't work? Cause Im a bit confused that you give me that:/ krisxxxz 45 — 9y
0
Oops, I didn't mean to add CFrame to that list, that was for another person, also I added Vector3 because it is typically best to use them inside of CFrame. perhaps since I was thinking of CFrame I added it to the list? I'll edit it. Scarious 243 — 9y
View all comments (2 more)
0
oh ok. Thanks for editing it. krisxxxz 45 — 9y
0
And, I almost forget to ask you about the teleporter, about the Reciver Variable cause it look a bit weird and I have a bad feeling about it. krisxxxz 45 — 9y
Ad

Answer this question