Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

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)

2 answers

✓ Accepted answer

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)

1 comment

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.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.