Anyone know how to make a ClickDetector for one Player only? I can make the rest of the Script, just not the ClickDetector for one person.
COMMUNITY QUESTION
ClickDetector for one Player only?
1 answer
Use a LocalScript with FilteringEnabled (game.Workspace.FilteringEnabled = true) and have the LocalScript add a ClickDetector to a part and connect a clicked event to it.
-- LocalScript
local player = game.Players.LocalPlayer
local playerAllowed = "YourName"
if player.Name ~= playerAllowed then return end
local click = Instance.new("ClickDetector")
local part = game.Workspace:WaitForChild("ClickPart")
click.Parent = part
click.MouseClick:connect(function()
print("Clicked by", player, ";", script) -- This is debugging so you know it did for sure come from that player.
-- Your code here
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
