Click Detector Not Working

CLICK DETECTOR NOT WORKING

In a game im helping create I created a hitbox which attaches to player torso, within the hitbox there is a click detector. However when I run the game the clickdetector doesn’t seem to be active(Clicks don’t work and the cursor doesn’t change appearance)

I’ve tested it through and it appears the Clickdetector doesn’t work when it is welded to the player.

‘ServerCode’

game.Players.PlayerAdded:Connect(function(player)
		player.CharacterAdded:Connect(function(character)
				local hitbox = game.ServerStorage.HitBox:Clone()
				hitbox.Parent = character.Torso
				hitbox.Transparency = 1
				local weld2 = Instance.new("Weld", character.Torso)
				weld2.Parent = character.Torso
				weld2.Part0 = character.Torso
				weld2.Part1 = hitbox
		end)
end)

Your game is R6 correct? If your game is not R6 then players (that are R15) will not have a torso, but rather a Upper and Lower Torso, and a HumanoidRootPart!

Well the game is r6 so it is the torso.

Um, where here is the Click Detector? I am very confused. Could you provide us with more details? Also, have you tried making a print statement for the detector to see if it actually works or not? I recommend you put a print statement in the first line of the detection function and see if it prints.

Going on to what @Batimius said about where the click detector is, have you made sure the click detector is actually there, after the cloning.

So is the hitbox a child of the players torso? or is it not welding to the player? What exactly isn’t working?

It is a child and welded to the torso and yet there is no click option

1 Like

That is different. Make the hitbox bigger than the character. It could be that something else is clipping it so it doesn’t display it. Also, make sure the distance is large enough.

Try this but in a Local Script

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
	local model = mouse.Target:FindFirstAncestorOfClass('Model')

	if model then
		local playerClicked = game.Players:GetPlayerFromCharacter(model)
		
		if playerClicked then
			print(playerClicked.Name)
		end
	end
end)
1 Like

Try making the Transparency .99.
I remember a few years ago putting a Decal on a Transparent Part and having the same issue.

You can’t click on descendants of your character. Parent the button to workspace instead of the torso.

It works but only to yourself, meaning you can click yourself now but not others.

I have check in studio and my code my previous post should work. Please let me know if it displays any errors.