I’m making a C4 system, but I’m having trouble welding or sticking the C4 to the ray casted part.
local raycastParams = RaycastParams.new()
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 = CFrame.new(cast.Position, cast.Position + cast.Normal)
weldTogether(c4, cast.Instance)
end
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?