How do I make it so a part can be continuously passed on if part is touched?

Hi there, I have a script that passes a bomb to a player by parenting the bomb and it’s necessary parts to the user. The issue is, is that this only works once, meaning I can pass the bomb to a user, but they can’t pass the bomb to anyone else. How could I achieve this? I have an idea of running the function every time the user touches something valid, however I’ve kinda already done that in the function provided below.

Note: Part2 is the bomb and RandomPlayer is the selected player at the start of the script, which a random bomb is passed to.

humanoid.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Torso") and hit.ClassName == "Part" then
		if not istouched then
			istouched = true
			local hittorso = hit.Parent:FindFirstChild("Torso")
			local hithead = hit.Parent:FindFirstChild("Head")
			local hithumanoid = hit.Parent:FindFirstChild("Humanoid")
			RandomPlayer = hithumanoid.Parent

			print(hit.ClassName)
			Part0.Parent = hittorso
			Part2.Parent = hittorso
			WeldConstraint1.Part1 = hittorso
			weld1.Part1 = hittorso
			Part0.Orientation = hittorso.Orientation + Vector3.new(-90,0,0)
			Part0.Position = hittorso.Position + Vector3.new(0,0,-0.75)
			Part2.Position = hittorso.Position
			beeping.Parent = hithead
			beeped.Parent = hithead
			explosionsfx.Parent = hithead
			wait(3)
			istouched = false
		end
	end
end)

You can have a variable of the owner, and everytime the bomb is touched, check if it isn’t the owner, then pass it

local owner = nil

bomb.Touched:Connect(function(hit)

   if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= owner then
      owner = hit.Parent
      --do whatever you wanna do, pass the bomb or anything else
   end

end)

Adjust this script accordingly

1 Like

I can’t tell if this works or not, you mind joining me at some point to test?

You can test it with 2 players alone, there is such a future in studio, you can also test it on a dummy

1 Like

No, it still doesn’t pass the bomb to the other player. I can pass the bomb on the first go, but they can’t

Yeah I can’t, my computer can’t handle multiple clients running at the same time. You mind if I give you the script to look at in PM’s?

You can post the script here, so that if we come to a solution others with similar goals can get help from this post