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

"Attempt to index local 'door' (a nil value)" Error. Can someone help me?

Asked by 9 years ago

I am trying to make my door slide up when a Text button on a surfaceGui is clicked on. Here is my script:

01    local door = game.Workspace.DoorSpawn7
02    local newPos = door.Position + Vector3.new(0,40,0) -- the position the Part will go to
03    local Time = 10 -- the time that the script will take to move the part
04    local Increment = 0.5 -- the Part will move 0.5 studs each time it moves
05    local Debounce = false
06    local Diff = newPos - door.Position -- the difference between the two positions
07    local Mag = Diff.magnitude -- the distance between the two parts
08    local Direction = CFrame.new(door.Position, newPos).lookVector
09    local TxtBox = door.SurfaceGui.TextLabel
10 
11function onTouch(door) -- The function that runs when the button is clicked.
12    if Debounce then return end
13    Debounce = true
14    TxtBox = 'Door Is Now Openning...'
15        for n = 0, Mag, Increment do
View all 23 lines...

I'm not sure what the error is. I'm new to LUA but have experience with other scripting languages (javascript.) Also, I looked up this error, and found a Related Question similar to the problem i'm having. What I understood from the answer and other commenters who answered to the error. Is that for example, you can't change the meaning of a variable and then try to get the original by calling it back but instead get the changed one, probably not the best example but hopefully this was enough information to help solve the problem and know where I stand in my understanding of this error. Thank you for your help in advance, Addictedroblox1414.

1 answer

Log in to vote
0
Answered by 9 years ago

Try adding a function.

0
There is a function in my script called onTouch. I'm not sure what you mean by to try adding a function. addictedroblox1414 166 — 9y
Ad

Answer this question