Welded part is not in the correct spot I wish it to be in

I’m trying to weld this part to the players hand, but the issue is that it does quite the opposite; While still being attached to the arm in the sense that it moves along with it, the part is always on some spot far away from where I intended it to be on (It’s on the sky in this example).

I’ve tried this with both regular Welds and WeldConstraints.

image

Here is the script (This is the only bug in this code for clarification, )

local ServerStorage = game:GetService("ServerStorage")
local lightningParticle = ServerStorage:FindFirstChild("lightningParticle")
local lightningLight = ServerStorage:FindFirstChild("lightningLight")
local streamSound = ServerStorage:FindFirstChild("streamSound")
local lightningStream = ServerStorage:FindFirstChild("lightningStream")
local streamEvent = game.ReplicatedStorage:FindFirstChild("Stream")

local debounce2 = {}

game.Players.PlayerAdded:Connect(function(player)
	local cooldown = tick()
	debounce2[player.Name] = 1
end)

streamEvent.OnServerEvent:Connect(function(player)
	if (tick() - debounce2[player.Name]) > 10 then
		debounce2[player.Name] = tick()
		local humanoidRootPart = player.Character.HumanoidRootPart
		local hand = player.Character.RightHand
		local particleClone = lightningParticle:Clone()
		particleClone.Parent = humanoidRootPart
		local lightClone = lightningLight:Clone()
		lightClone.Parent = humanoidRootPart
		local streamClone = lightningStream:Clone()
		streamClone.Weld.C0 = streamClone.CFrame
		streamClone.Parent = hand
		streamClone.Weld.Part1 = hand
		streamClone.Weld.C1 = hand.CFrame
		local soundClone = streamSound:Clone()
		soundClone.Parent = humanoidRootPart
		soundClone:Play()
		game.Debris:AddItem(particleClone, 5)
		game.Debris:AddItem(lightClone, 5)	
		game.Debris:AddItem(streamClone, 5)
		game.Debris:AddItem(soundClone, 5)
	end
end)

C0 and C1 are offsets, not absolute positions.

Set them both to CFrame.new() (or just delete those lines) and your part will be welded exactly to the center of your arm.

Set C0 to CFrame.new(0, -1, 0) and your part will be put at the bottom of your arm (your hand)

Another option would be to use WeldConstraints instead of Welds. Unlike Welds, WeldConstraints dont reset the position of the part.

1 Like

And we would use something like CFrame.Angles to offset the orientation, correct?

Yes, you can use CFrame.Angles with radians to rotate the part to a specific orientation.