door = script.Parent; locked = true function setform(v) locked = v if v then door.Transparency = 0 door.Reflectance = 0.4 door.CanCollide = true else door.Transparency = 0.7 door.Reflectance = 0 door.CanCollide = false end end function click() if locked then setform(false) wait(5) setform(true) end end door.ClickDetector.MouseClick:connect(click)
Actually, with the unused Click
parameter returned though the ClickDetector
's MouseClick
Signal, we can apply it in your "Click()
" function.
That parameter actually give the PlayerObject
of who Clicked, so we can get their Name, preferably UserId for versatility, to debounce the function from running if they don't match
local UserId = { -- Players' UserIds that can open the Door (In a table so you can compare multiple. }; function Click(Player) if (Player.UserId ~= UserIds[Player.UserId] then return end -- Everything else end