I want to make a door that that opens when you click a button, although I am unsure how to do it.
I am new to ClickDetector
I want to make a door that that opens when you click a button, although I am unsure how to do it.
I am new to ClickDetector
ClickDetector is pretty easy, you utilize MouseClick event that fires once the player clicks its parent. Insert a ClickDetector in the part where you want to click to. Then insert a script not LocalScript inside also the part where you want to click to.
local clickDetector = script.Parent.ClickDetector
local door = game.Workspace.DoorName
local open = false
clickDetector.MouseClick:Connect(function(plr)
if open == false then
open = true
door.Transparency = 0.5
door.CanCollide = false
-- Door is open
else
open = false
door.Transparency = 0
door.CanCollide = true
-- Door is closed
end
end)
This is just a simple way. You can do a lot more.
You can do something like this:
function OnClicked()
script.Parent.Parent.secret.Transparency=1
script.Parent.Parent.secret.CanCollide=false
wait (60)
script.Parent.Parent.secret.Transparency=0
script.Parent.Parent.secret.CanCollide=true
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)
Just change the word secret to the name of the part you want to affect, if the part being affected is called "Part", just rename it to something else.
Hope this helped :D
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Bookmarked. I'll write some code for you when I wake up!