my code:
game.workspace.Door.MouseButton1Click:connect(function(plr)
wait(5)
end)
if
game.Workspace.Door.MouseButton1Click.Triggerd then
game.Workspace.Door.Transparency = 0.5
end
The error:
MouseButton1Click is not a valid member of Part “Workspace.Door”
Uhhh, first of all MouseButton1Click is an event that triggers when the person clicks.
2nd of all, you aren’t even referencing the ClickDetector. I’m pretty sure its MouseClick, not MouseButton1Click, and I recommend you do not put this in a server script if you do not want it to open for other players.
Certainly, the API doesn’t exist on ClickDetector and you’re confusing it with a GUI button’s API. Use MouseClick. To appropriately rewrite this simple mechanic:
workspace.Door.MouseClick(function(plr) -- this only turns the transparency
workspace.Door.Transparency = 0.5
wait(5) -- why is this here
end)
Elaborate script is here:
local isOpen, isToggling
workspace.Door.MouseClick(function(plr)
if isToggling then -- debounce
return
end
isToggling = true
if not isOpen then -- if statement, separating opposing settings
workspace.Door.CanCollide = false
workspace.Door.Transparency = 0.5
else
workspace.Door.CanCollide = true
workspace.Door.Transparency = 0
end
wait(5)
isToggling = false
end)