local cd = game.Workspace.Part.ClickDetector cd.MouseClick:Connect(function() print("Yes") end)
Every tutorial makes getting the player who triggered it way harder than I think it is supposed to be. Can someone show something simple?
If you look at the documentation the player who clicked the clickdetector is passed along in the event: https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick
Example:
cd.MouseClick:Connect(function(player) -- put your code here end)
Edit: Touched only passes the other part that touched the part you put the event on. However you can still quickly obtain the player:
part.Touched:Connect(function(hitPart) local otherPlayer = game.Players:GetPlayerFromCharacter(hitPart.Parent) if otherPlayer then -- put your code here end end)
The reason we need the extra if statement is because if the part does not belong to a player, it would fail.
Additionally you have to keep in mind that any accessories/tools the player has will not be picked up using this method. This is because the handle or whatever other part of inside of them it's parent will be the Accessory or Tool instance. Meaning this will fail. However for starters I wouldn't yet worry about this.