#Key door doesn't work (Trying to destroy tool after opened)

12 messages · Page 1 of 1 (latest)

undone tapir
#
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        print(char.Name)
        
        local folder = workspace.Doors
        
        local collectibles = workspace.Collectibles
        
        local path = folder.EntranceDoor
        
        for i, v in pairs(folder:GetChildren()) do
            v.Touched:Connect(function(hit)
                if hit.Name == "KeyOpener" then

                    --local tool = char:WaitForChild("Entrance Key")
                    --warn(tool)

                    path.Open:Play()
                    path.Anchored = false
                    path.CanCollide = false

                    --tool:Destroy()

                end
            end)
        end
    end)
end)

(ServerScript) Any idea why the code snippets with dashes don't work and break the script?

lone parrot
#

they are comments

#

they are used to leave stuff like notes

#

so thats why it wont work

undone tapir
#

I know,

#

those are just an indication.

#

it does still not work if i remove the comments.

#

@lone parrot

lone parrot
undone tapir
#

I did, the script doesn't work. It just breaks.

lone parrot
#

errors?