I’m trying to make a button that uses clickdetector that only I can press and noone else. If that’s not possible with clickdetector is there something similar that is physically based and not GUI based that I can do?
1 Like
Pretty easy, just use an if then statement.
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if plr.UserId == your players user id then
whatever you want to happen
end
end)
1 Like
Simply check if the person who clicked it’s name is equal to your name thorough an if statement
There are two ways to do this. Either let everyone click it and do nothing if they’re not you. Or on player join and if your character is near the part you can enable the detector and then put an if statement to make sure.
1 Like
or you could be more secure and use id
1 Like
I’d recommend something like this
ClickDetector.MouseClick:Connect(function(player)
if player.UserId ~= game.CreatorId then
return
end
--Your code that you want to happen when you click on it
end)
There’s already a property to get the user id of the owner of the game, though this will not work if the creator of the game is a group
2 Likes