Sticky Bombs not taking orientation of raycasted part

I’m making a C4 system, but I’m having trouble welding or sticking the C4 to the ray casted part.

local raycastParams =
raycastParams.FilterDescendantsInstances = {workspace.Thrown}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

local c4 = game.ReplicatedStorage.C4:Clone()

local cast = workspace:Raycast(c4.Position, c4.CFrame.LookVector * 300, raycastParams)
if cast and cast.Instance and cast.Instance.Transparency < 1 and cast.Instance.CanCollide then
	c4.CFrame =, cast.Position + cast.Normal)
	weldTogether(c4, cast.Instance)

c4.Parent = workspace.Thrown
game.Debris:AddItem(c4, 1)

This code leads me to this. While it does weld to the part, it’s obviously not in the correct orientation.

How would I properly weld the C4 with the correct orientation?

It seems like you’d either have to change the orientation of the model in studio, or offset in in the script (hint: orient CFrame using something like cf * CFrame.Angles(math.pi / 2, 0, 0) (might need to change which axis it’s on, or if it’s positive or negative)).
Also, you should use CFrame.lookAt for your use case, as, lookAt) is deprecated.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.