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!