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

How do I make a click detector only available for certain players?

Asked by 4 years ago

I don't really know how to get player names. I assume it's something like

local button = game.Workspace.Button

button.ClickDetector.MouseClick:Connect(function()
    if Player.Name = "RogueSalvation", "friend" then
        -- Code
    end
end
0
Yeah, kinda like that. You would have to get the player who clicked, and see if there name matches. So put player in the empty (player) zandefear4 90 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

To access the player, you would put player in the empty brackets (player). That will be the player who clicked. Then .Name is self-explanatory.

local button = game.Workspace.Button

button.ClickDetector.MouseClick:Connect(function(player) --player is the player who clicked
if player.Name == "RogueSalvation" or "" then --Not sure if it can access to see who your friends are
    --code
end
end)
0
Sorry, didn't see his answer. Not sure if you can access friends like that, maybe you can. But if you didn't want all of them to be able to access it, you would do if it equals your name, friends and does not equal ~= that persons name then. zandefear4 90 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
local button = game.Workspace.Button

button.ClickDetector.MouseClick:Connect(function(player) --Insert the parameter (the player who clicked)
    if player.Name == "RogueSalvation" or "friend" then --make sure to use the double equal sign, use or to indicate one or the other
            -- Code
    end
end)

Answer this question