So im trying to make a button that when clicked turns green and makes a door disappear. But i also want that when clicked again, it turns red and makes the door appear again, as if it was a toggle basically. I’ve looked up some posts in the forums and videos on YT and tried mimic what they did since my original attempts weren’t working but to no luck, it still doesn’t work even though it looks simple…so im lost and now come for help
This is my current script, already deleted the part that wasn’t working. So far, it has the part that turns it green/open status and disappear the door model working properly. Any help is appreciated. Thanks for your time.
local door = script.Parent.Parent.DoorBarricade1
local descendants = door:GetDescendants()
local button = script.Parent
local ClickDetector = workspace.Objectives.ButtonDoor.Button.ClickDetector
local activated = false
ClickDetector.MouseClick:Connect(function()
if activated == false then
button.BrickColor = script.Parent.ButtonOpen.Value
workspace.Objectives.ButtonDoor.Button:FindFirstChild("button"):Play()
workspace.Objectives.ButtonDoor.Button:FindFirstChild("Door Close"):Play()
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("BasePart") then
descendant.Transparency = 1
descendant.CanCollide = false
activated = true
end
end
end
end)