Yeah So For Another One Of My Games,I Am Gonna Put A Door That Players Can Click So When They Click,It Opens.But Since I Have Got 2 Seperate Bits Of The ClickDetector The Door Doesn't Open?
Here It Is:
local clickdetector = script.Parent:WaitForChild("ClickDetector") clickdetector.MouseClick:Connect(function(player) workspace["Door"].Transparency = 1 workspace["Door"].CanCollide = false end) local clickdetector = script.Parent:WaitForChild("ClickDetector") clickdetector.MouseClick:Connect(function(player) workspace["Door"].Transparency = 0 workspace["Door"].CanCollide = true end)
To fix this you're going to want to combine the two using an if statement and a boolean to check after the player has clicked the button. If they did then make the boolean true or false depending if its open or closed.
local clickdetector = script.Parent:WaitForChild("ClickDetector") local doorOpened = false clickdetector.MouseClick:Connect(function(player) if doorOpened == false then --If our door is closed then continue our next code doorOpened = true --Make our boolean true since its closed workspace["Door"].Transparency = 1 workspace["Door"].CanCollide = false else --If door is already open then instead do: doorOpened = false workspace["Door"].Transparency = 0 workspace["Door"].CanCollide = true end end)