Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make it so only a specific person can open this door?

Asked by 5 years ago
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)

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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
0
I don't understand where exactly I put that script above. GarrettlovesGTA -1 — 5y
0
local function pls XD User#5423 17 — 5y
Ad

Answer this question