I’m having some issues with the ClickDetector’s and its probably my fault but I can’t seem to find it…
From the docs: “They work when parented to BasePart, Model, or Folder objects.”
I have a StarterPlayerScripts localscript that looks for models parented under a folder in workspace, then, it links to the ClickDetector from each model, and when clicking, locks player movement and moves the clicked model instead.
I have a couple of test models, one is made of parts, and one is made of a MeshPart, when clicking on the model made of parts, code runs as expected, when clicking on the meshes, it doesn’t do anything.
I attached a video and a couple screenshots with the issue and hierarchy, I also used the Roblox example ClickDetector code from the docs and its the same issue.
This is the relevant code, that print statement connecting the mouseclicks doesn’t trigger with MeshPart’s
for _, roomba in pairs(workspace.roombas:GetChildren()) do
if roomba:FindFirstChild("ClickDetector") then
print('found roomb ', roomba)
roomba.ClickDetector.MouseClick:Connect(function(player)
print(player, roomba)
controlRoomba(player, roomba)
end)
end
end
Hmm, I changed it to “WaitForChild” and still had the same issue, also of note, the print debug statement works when finding the clickdetector, so its not that either…
Are you trying to print the names of the player and the roomba? Right now you’re trying to print the actual player and roomba and not the name of them.
for _, roomba in pairs(workspace.roombas:GetChildren()) do
if roomba:FindFirstChild("ClickDetector") then
print('found roomb ', roomba)
roomba.ClickDetector.MouseClick:Connect(function(player)
print(player.Name, roomba.Name)
controlRoomba(player, roomba)
end)
end
end
Not really, the print statement there was just for a debug, to make sure the correct player is being picked up as well as the correct (clicked on) roomba.
I found that the MeshPart had a click detector under it, which seems to have been causing the issue: “If multiple ClickDetectors may detect user input, only the deepest will fire events…” - Docs