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
Script:
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
v.Touched:Connect(function(hit)
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)
task.wait(1)
canpass = true
else
return
end
end)
end
end
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.
workspace:GetPartsInPart()
or workspace:GetPartBoundsInBox()
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.
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!
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