Well I know it would be easy to make a door disappear and reappear by using an onTouch function and setting it's can-collide to be false and its transparency to fade to 1. But I need help. Is there any way that I can have a tool in my starterpack where if I click, the door dissappears, but if I click again, the door reappears? I already know how to do the script for the dissappearing part and the reappearing part, I just need someone to point me in the right direction.
Also, if this is not possible, I can settle for a button where if I click, it fades and if I click again, it reappears. I just don't know the function for it.
This is my fading script using an onTouch function. Hope that helps somehow.
Brick = script.Parent fading = false Brick.Touched:connect(function(part) if not fading then fading = true for i = 1, 10 do Brick.Transparency = Brick.Transparency + .1 wait(.1) end wait(2) Brick.Transparency = 0 fading = false end end)
local Brick = script.Parent Brick.Changed:connect(function(prop) if prop == "Transparency" then if Brick.Transparency >= 1 then Brick.CanCollide = false else Brick.CanCollide = true end end end)
You can listen for the Equipped event of a tool, get the mouse, then listen for a click, check if the door was clicked on, then take appropriate action. Here, I'll give you an example:
local door = workspace:FindFirstChild("Door") --change this to the location of the door script.Parent.Equipped:connect(function(mouse) if mouse.Target then if mouse.Target == door then --take appropriate action here end end end)