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

Will these button doors work?[NEEDS TO BE CHECKED AGAIN]

Asked by 10 years ago

The first script says that when someone steps on a brick called Button, another brick called Door will become transparent and walkthrough. The second one says that when someone clicks a part called Button, the part called Door will open. Will these work? [EDITED BY DUMMIEZ]

First script (Button Touch Door)

local debounce = true
function onTouch(Button)
if debounce and Button.Parent:FindFirstChild("Humanoid") and Button.Parent.Name == game.Players:findFirstChild(Button.Parent.Name) then debounce = false
game.Workspace.Door.Transparency = 0.5
game.Workspace.Door.CanCollide = false
wait(5)
game.Workspace.Door.Transparency = 0
game.Workspace.Door.CanCollide = true
debounce = true
end end

script.Parent.Touched:connect(onTouch)

Second script (Button Click Door)

H = game.Workspace.Door

local debounce = true
function onTouch(Button)
if debounce and Button.Parent:FindFirstChild("Humanoid") and Button.Parent.Name == game.Players:findFirstChild(Button.Parent.Name) then debounce = false
function onClick(Button)
H.Transparency = 0.5
H.CanCollide = false
wait(5)
H.Transparency = 0
H.CanCollide = true
end end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
2
Answered by
Dummiez 360 Moderation Voter
10 years ago

These should work fine, however some improvements in the first script with Touched events, is that if you want only players or humanoids to active the door is to check if parent contains a Humanoid or search for the name on thegame.Players

First script:

local debounce = true
function onTouch(Button)
if debounce and Button.Parent:FindFirstChild("Humanoid") and Button.Parent.Name == game.Players:findFirstChild(Button.Parent.Name) then debounce = false
game.Workspace.Door.Transparency = 0.5
game.Workspace.Door.CanCollide = false
wait(5)
game.Workspace.Door.Transparency = 0
game.Workspace.Door.CanCollide = true
debounce = true
end end

script.Parent.Touched:connect(onTouch)

You can do the debounce with the second door as well.

0
Thank you Dummiez :D bloonblaster2000 55 — 10y
0
I edited the first and second scripts bloonblaster2000 55 — 10y
0
Yes these should work, make sure to put debounce = true in the second script or else it will always be false. Dummiez 360 — 10y
Ad

Answer this question