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

Why does this keycard script door unlock the door, but won't lock it again?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make a script where when a keycard is put in, it will unlock the door, and once put back in it will lock the door again. So far the script only locks the door, here's the snippet. Sorry if my code is messy:

script.Parent.Touched:Connect(function(hit)
    if hit then
        if hit.Parent and hit.Parent.ClassName == "Tool" then
            if Clearance[hit.Parent.Name] then
                if locked.Value == true then
                    if debounce then
                        debounce = false
                        locked.value = false
                        print(locked.Value)
                        wait(.2)
                        debounce = true
                        end
                    end
                    elseif locked.Value == false then
                        if debounce then
                            debounce = false
                            locked.Value = true
                            print(locked.Value)
                            wait(.2)
                            debounce = true
                        end
                    end
                end
                end
            end)
0
does it print? hellmatic 1523 — 5y
0
It prints false once, and then it stops working. CaptainAlien132 225 — 5y
1
You have an extra "end" on line 13. Fifkee 2017 — 5y

Answer this question