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

Door script not working?

Asked by 8 years ago
function onTouched(hit)
    script.Parent.Door.Transparency = 0.6
    wait(0.1)
    script.Parent.Door.CanCollide = false 
    wait(2)
    script.Parent.Door.Transparency = 0
    wait(0.1)
    script.Parent.Door.CanCollide = true

end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by
yoshi8080 445 Moderation Voter
8 years ago

Here is what was wrong with your script

1. You didn't what would hit the door (Which would be the humanoid)

function onTouched(hit)
    local h = hit.Parent:findFirstChild("Humanoid")
        if h~=nil then
             script.Parent.Door.Transparency = 0.6
            wait(0.1)
                script.Parent.Door.CanCollide = false 
            wait(2)
             script.Parent.Door.Transparency = 0
            wait(0.1)
             script.Parent.Door.CanCollide = true
                                                end
                                                    end

script.Parent.Door.Touched:connect(onTouched)

You can change the last line to however you set it as, I just added door, for it to work for me since, I don't know what the model is set up for the door.

Ad

Answer this question