"Attempt to index local 'door' (a nil value)" Error. Can someone help me?
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.DoorSpawn 7 |
02 | local newPos = door.Position + Vector 3. new( 0 , 40 , 0 ) |
05 | local Debounce = false |
06 | local Diff = newPos - door.Position |
07 | local Mag = Diff.magnitude |
08 | local Direction = CFrame.new(door.Position, newPos).lookVector |
09 | local TxtBox = door.SurfaceGui.TextLabel |
12 | if Debounce then return end |
14 | TxtBox = 'Door Is Now Openning...' |
15 | for n = 0 , Mag, Increment do |
16 | door.CFrame = door.CFrame + (Direction * Increment) |
17 | wait( (Time/Mag) * Increment ) |
23 | script.Parent.MouseButton 1 Click:connect(onTouch) |
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.