Touch Event not working correctly

So im trying to make a Touch Event whereas when you touch a player as the “Defected” it tranfers your title to them but this event only works once or not at all(had to join the game on roblox and try a few times to get results)

All Help Is Appreciated in advance


	local char = HotPotatoHolder.Character
	for i, v in pairs(char:GetChildren()) do
		if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("BasePart") then
				if hit ~= nil and hit.Parent.Name ~= char.Name and Players:GetPlayerFromCharacter(hit.Parent) and canpass == true then
					canpass = false

					HotPotatoHolder = Players:GetPlayerFromCharacter(hit.Parent)

					HotPotato.Parent = hit.Parent
					Highlight.Parent = hit.Parent
					print("Passed Highlight and Hot Potato to "..hit.Parent.Name)
					canpass = true
1 Like

Touch events are very unreliable. Sometimes firing, sometimes not. And also seems to not work if CanCollide property is false, even if CanQuery and CanTouch is true? its very strange.

or workspace:GetPartBoundsInBox()

might help you out

1 Like

If you were to go down this route, you would need to add it into a loop. And I would also add OverlapParams to filter out all parts which are not needed.

1 Like

Need more of the code, too much undefined. Where is the script located?

1 Like

Server script in server script service

Ill look more into it, but could you give an example on how it would be used instead of a Touched Function? How would i imply the loop or whatever is needed to keep it checking?

From what i understand, you need to loop the hitbox and if a player touches the hitbox and the player with the hitbox has the potato, you give it to them, but I might just be completly wrong, I never used that command before.
Have a great day!:grinning:

1 Like

You would need to check if the part that touches the hitbox is a children of a player’s model.

1 Like

Should I make the hit box a players character lr should I make another part because I’m pretty sure the touch event uses whatever BoundsBox an object is in to detect if anything touches it