I’m trying to make a system where players can double-click on a player to reveal their career using click detectors. However, when parenting the click detector to my character, the click detector won’t work. It does when parented to other characters except my own.
The problem you are encountering is related to the behavior of ClickDetectors when parented to a player-controlled object. Here are some things that can help you better understand and resolve this problem:
ClickDetectors do not work properly on objects that belong to a player’s character, as Roblox generally prevents physical or scripted interactions between a player and their own character. This includes clicks, collisions, and other interactions that could be considered problematic for game balance or to avoid endless click loops.
Move the ClickDetector
One solution is to move the ClickDetector to a location that is not directly related to the player character. For example :
Place the ClickDetector in an external part or model, and use scripts to transfer interactions to the character if necessary.
For example, you can use a proxy to represent the character and then pass the clicks like this:
local ClickDetector = workspace.Part.ClickDetector
ClickDetector.MouseClick:Connect(function(player)
print(player.Name .. " clicked on the object.")
end)
If you want your character to be able to “interact” with the ClickDetector in a scripted way, you can also use a RemoteEvent to synchronize the interaction between the client and the server. For example :
On the client: detect a click using UserInputService or custom mechanisms.
On the server: manage the effect of this action as if the player had clicked on the ClickDetector.
I hope this helps you solve your problem! If you have any other questions or code examples to share, don’t hesitate.