Hug tool keeps colliding

Hello, so I am trying to make a hug tool, a player walks up to a player makes contact, then it teleports the player near him/her and the player needs to stay in that spot while animation (hug) is being played, the player can walk around while giving them a hug. I have tried to make this, it keeps colliding with the player, how would I solve this? I have heard of physics groups but cannot figure it out, if anyone can help that would be amazing.


local tool = script.Parent
local using = false

local Hug = script.AnimationID1

local function TouchedPart(human)
	if human:FindFirstChild("Hug") then
		if human:FindFirstChild("Hug").Value == true then
			return false
		end
	end
	
	if script.Parent.Parent:FindFirstChild("Hug") then
		if script.Parent.Parent:FindFirstChild("Hug").Value == true then
			return false
		end
	end
	
	if not human:FindFirstChild("Hug") then
	local Hug1 = Instance.new("BoolValue")
	Hug1.Parent = human
	Hug1.Name = 'Hug'
	Hug1.Value = true
	else
		human.Hug.Value = true
	end
	
	if not script.Parent.Parent:FindFirstChild("Hug") then
		local Hug1 = Instance.new("BoolValue")
		Hug1.Parent = script.Parent.Parent
		Hug1.Name = 'Hug'
		Hug1.Value = true
	else
		script.Parent.Parent.Hug.Value = true
	end
	
	
	
	
	if using then
		human.UpperTorso.Anchored = false
	end
	
	local dance1 = script.Parent.Parent.Humanoid:LoadAnimation(Hug)
	
	for i, v in pairs(human:GetChildren()) do
		if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("Part") or v:IsA("MeshPart") then
			v.CanCollide = false
			print(v.Name)
		end
	end
	
	dance1:Play()
	dance1.Looped = true
	
	local dance2 = human.Humanoid:LoadAnimation(Hug)
	dance2:Play()
	dance2.Looped = true	
		
	while using and wait() do	
		if using == true then	
		human.UpperTorso.CFrame = script.Parent.Parent.UpperTorso.CFrame * CFrame.new( 0, 0, -2.8 )
			human.HumanoidRootPart.Orientation = Vector3.new(0,-90,0)
		else
			dance1.Looped = false
			dance1:Stop()
			dance2.Looped = false
			dance2:Stop()
			human:FindFirstChild("Hug").Value = false
			script.Parent.Parent:FindFirstChild("Hug").Value = false
	end	
	end
end


tool.Equipped:Connect(function()
	local animation = script:WaitForChild('AnimationID')
	local humanoid = script.Parent.Parent:WaitForChild('Humanoid')
	local dance = humanoid:LoadAnimation(animation)
	dance:Play()
	dance.Looped = true

	local part = Instance.new("Part")
	part.Size = Vector3.new(5, 4.999, 3)
	part.CanCollide = false
	part.Anchored = false
	part.Transparency = 1
	part.Position = script.Parent.Parent.HumanoidRootPart.Position
	part.Orientation = Vector3.new(0, 0, 0)
	part.Parent = workspace

	local weld = Instance.new("WeldConstraint")
	weld.Parent = script.Parent.Parent.HumanoidRootPart
	weld.Part0 = part
	weld.Part1 = script.Parent.Parent.HumanoidRootPart

	part.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if hit.Parent.Name == script.Parent.Parent.Name then

			else
				using = true
				part:Destroy()
				TouchedPart(hit.Parent)
			end
		end
	end)

	tool.Unequipped:Connect(function()
		using = false
		dance:Stop()
		dance.Looped = false
		part:Destroy()
		weld:Destroy()
	end)
end)```
This is what I have so far in the script.
1 Like

Can you temporarily set the WalkSpeed to 0 to prevent movement, as well as JumpPower?

1 Like

When I do this, They still end up colliding.

1 Like

Is it the tool that’s colliding or the players?

1 Like

As of right now, the player are colliding. You can just paste that script into a tool with a handle in a server script, just take out the animation parts and you will see.

1 Like

Try a .Touched event for every part within the character and make sure it prints both touching parts, so you can see what actually is colliding.

1 Like

So, I used Detecting Collisions | Roblox Creator Documentation and just mad it so that every player can collide with each other, I think now I just weld the other player to the current player?

1 Like

That may work, although you might want to anchor the HumanoidRootPart if not done already.

1 Like