Log in to vote
0

Button door help? [closed]

Asked by 7 years ago

So basically, the script is about when a player steps on a part called Button, a message appears, dissapears, and the door opens, stays open for 10 seconds, and closes again. Is this right?

Message on touch script

local debounce = true
function onTouch(Part)
if debounce and Button.Parent:FindFirstChild("Humanoid") and Button.Parent.Name == game.Players:findFirstChild(Button.Parent.Name) then debounce = false
function onTouch(Part)
Instance.new("Message", game.Workspace.Part)
wait()
H.Message.Text("You can pass.")
end

script.Parent.Touched:connect(onTouch)

Door script

H = game.Workspace.Door

function onTouch(Button)
wait(5)
H.CanCollide = false
H.Transparency = 1
wait(10)
H.CanCollide = true
H.Transparency = 0
end

script.Parent.Touched:connect(onTouch)
0
What's the error? TurboFusion 1821 — 7y

Locked by Shawnyg and AmericanStripes

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Shawnyg 4251 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
7 years ago

Put this in the button.

door = game.Workspace.Door
button = script.Parent
button.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        p = game.Players:GetPlayerFromCharacter(hit.Parent)
        door.Transparency = 1
        door.CanCollide = false
        m = Instance.new("Hint", p.PlayerGui)
        m.Text = "You may now pass."
        wait(10)
        m:Destroy()
        door.CanCollide = true
        door.Transparency = 0
    end
end)
Ad