I am working on a rpg and the weld script I use for the swords works fine in studio, but in playing the game for some reason the weld doesnt work. theres no output V my weld script

handle = script.Parent:WaitForChild("Handle")
tool = script.Parent
function weld(part)
	local w1 = Instance.new("Weld")
	w1.Part0 = handle
	w1.Part1 = part
	w1.C0 = handle.CFrame:inverse()
	w1.C1 = part.CFrame:inverse()
	w1.Parent = tool
end

for _, part in pairs (script.Parent:GetChildren()) do
	if part:IsA("BasePart") and part.Name ~= "Handle"then
		weld(part)
	end
end

the model the script is in is in a folder in lighting if that matters

8 comments

0

You have an extra end. If there is more of the script then you would need local in front of your variables. But that might just be how you posted the question.

0

The ends look right to me.

0

You also might want for line 12 "if part:IsA("BasePart") then"

0

Also try setting the parent of the weld last in the function

0

ok

0

Ands look a lot like ends xD srry

0

Are you welding it every time it is equipped?

0

No its not a tool, its a model, the parts are welded to the handle and the handled to the plays arm