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

Printing nil when my body parts touches the hitbox? * SOLVED *

Asked by
notfenv 171
4 years ago
Edited 4 years ago

Currently, I am working on a TweenService key card door. I have been trying to figure this issue out for a very long time, but whenever my body part touches the scanner/hitbox, it says "Attempt to index a nil value", but it still opens and function, the line that's printing this is just below function check(hit), help?

http://prntscr.com/qe6qg6

--// Functions

function check(hit)
if hit.Name == "Handle" and script.Parent.DoorData:FindFirstChild(hit.Parent.Name).Value    and debounce == false and script.Parent.DoorData.InUse.Value == false and script.Parent.DoorData.Open.Value == false then
        sounds.AccessGranted:Play()
        debounce = true
        wait(0.5)
        open(hit.Parent.Name)
        wait(2)
        sounds.Alarm:Play()
        wait(1.7)
        close()
        debounce = false
        elseif hit.Name == "Handle" and not         script.Parent.DoorData:FindFirstChild(hit.Parent.Name).Value and not debounce then
        debounce = true
        sounds.AccessDenied:Play()
        wait(1)
        debounce = false
        end
    end

Hitbox.Touched:Connect(check)

Answer this question