Welding a part to player's character

Hello! I am trying to make a sticky bomb where you throw it and it sticks to a person (just like in Ragdoll Engine). I have the system for throwing the sticky bomb and it all works, but welding it to a player is something I am having problems with.

I’ve tried doing it and it just flips the character underneath the map.

Bomb = script.Parent
Bomb.CanCollide = false

debris = game:GetService("Debris")



local hitsounds = {"19326853", "19326880", "19326891"}

local HitSound = Instance.new("Sound")
HitSound.SoundId = "rbxassetid://" .. hitsounds[math.random(1,#hitsounds)]
HitSound.Parent = Bomb
HitSound.Volume = 1



function onTouched(hit)
	connection:disconnect()
	HitSound:Play()
	if hit.Parent then
		if hit.Parent:findFirstChild("Humanoid") then
			local part = hit
			local weld = Instance.new("Weld")
			weld.Part0 = part
			weld.Part1 = Bomb
			
			weld.C0 = part.CFrame:Inverse()
			weld.C1 = Bomb.CFrame:Inverse()
			weld.Parent = Bomb
		
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5
		elseif hit.Parent.Parent:findFirstChild("Humanoid")	then
			hit.Parent.Parent.Humanoid.Health = hit.Parent.Parent.Humanoid.Health - 5
		end
	end
	Bomb.ParticleEmitter.Enabled = true
	Bomb.Transparency = 0
	Bomb.Anchored = true
	wait(2)
	Bomb.ParticleEmitter.Enabled = false
	wait(2)
	Bomb:Destroy()
end

connection = Bomb.Touched:connect(onTouched)

Thanks!

That’s likely because the bomb is anchored, unanchor it before you weld it to the player’s character.

Still not working for some reason. Sometimes it works but sometimes it doesn’t.

Never seen that before

Idk if this will solve the issue

local part = hit
			local weld = Instance.new("Weld")
			weld.Part0 = Bomb
			weld.Part1 = part
         Bomb.Anchored = true
	local cf = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame) -- find offset from part1 relative to part0
	weld.C0 = cf
	
	weld.Parent = weld.Part0
	Bomb.Anchored = false

try using a weldconstraint instead, then use the part it hit

1 Like