Let's say I have a click detector like this:
script.Parent.ClickDetector.MouseClick:connect(function() local player = --this Is what I want to know how to get local f = script.Parent f.Parent = player.Backpack end)
How do I get the player? I know with a brick touch you can:
function onTouch(f) local player = game.Players:GetPlayerFromCharacter(f.Parent) end script.Parent.Touched:connect(onTouch)
and you can get the player like that through touch, but in the situation I'm in I don't want to use a brick touch. Is there a similar way for click? If you can help please do! Thanks!
ClickDetector's event MouseClick
is already emitted with a argument of who the player is that clicked the Part.
script.Parent.ClickDetector.MouseClick:connect(function(playerclicked) -- Here's the argument local f = script.Parent f.Parent = playerclicked.Backpack end)
You can simply use an argument with it... Something like his
script.Parent.ClickeDetector.MouseClick:connect(function(player) if player then local f = script.Parent f.Parent = player.Backpack end end)