Sticky Bomb Help - Scripting Support

Hi, I have a sticky bomb but am having trouble with the sticking part of the bomb. Looks like I’m in a sticky situation :wink: … anyway. Here is the current piece of code I have and when the bomb lands, it disappears or goes somewhere far away in the map.

				local weld = Instance.new("Weld")
				weld.Parent = hit
				weld.Part0 = hit
				weld.Part1 = Object
				weld.C1 = CFrame.new(mousePosition.p)

What am I doing wrong.
How can I fix this?
I need to use welds so I can stick bombs onto players.
Cheers,

2 Likes

Would this work?

local weld = Instance.new("Weld")
weld.Parent = hit
weld.Part0 = hit
weld.Part1 = Object
weld.C1 = CFrame.new(mouse.Hit.p)
1 Like

You’re setting the weld CF to the hit cf. This will cause the weld to stay where the player clicked. You need to set the weld CF to a CF based off the position and part on the clicked object. Or you can just weld the Part to the player and set the partCFrame to the click.

Hi, thanks for the reply, do you mind helping me code that?

Hi, thanks for the reply. This did not work unfortunately. Do you have anything else in mind?

It’s probably because it’s using the mouse’s position. You could use a WeldConstraint instead, since you don’t have to set the CFrame offset (as long as it’s already in the position you want it to be welded to)

I’ll try that, stay with me incase it doesn’t work. Thanks for the reply.

ok, so weld constraints don’t work, they still disappear.

Sort of, I think they go inside the object

Can you post your entire implementation (and maybe a video, that would be helpful)? I’m not getting enough information from just that little snippet

I think it’s because of my throwing script. Is there anyway I could use tweening to tween the object to the mouse hit position but have it tween in a throwing motion like shown in this terrible diagram:
image

Because then the object would be at the position and I just have to weld it. I think it’s not welding properly because where the sticky bomb lands is not the mouse position

Actually, nvm, that wouldn’t work because if players aim in the air…