Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Weld Script being weird?

So, I am writing a weld script for my rollercoaster car, and I will be able to use it for everything else. Anyway, It works, but for some reason, every piece go all weird, into weird places, but only on certain parts, not every piece. The code:

function weld(base, group)
	for i, v in pairs(group:GetChildren()) do
		if v ~= script.Parent.Welds then
local w = Instance.new("ManualWeld") 
w.Parent = base
w.Part0 = base
w.Part1 = v
w.C0 = (base.CFrame-v.Position)
		end
	end
end
weld(script.Parent.Brake, script.Parent)

I am not sure what is wrong... Any solutions, maybe?

2 comments

0

edit so that is works please, i think you messed up the code block thing

0

so do i... i thought i was just my computer at first.

1 answer

✓ Accepted answer

here use this weld script i use it all the time :)

function weld()
	local parts,last = {}
	local function scan(parent)
		for _,v in pairs(parent:GetChildren()) do
			if (v:IsA("BasePart")) then
				if (last) then
					local w = Instance.new("Weld")
					w.Name = ("%s_Weld"):format(v.Name)
					w.Part0,w.Part1 = last,v
					w.C0 = last.CFrame:inverse()
					w.C1 = v.CFrame:inverse()
					w.Parent = last
				end
				last = v
				table.insert(parts,v)
			end
			scan(v)
		end
	end
	scan(script.Parent)
	for _,v in pairs(parts) do
		--v.Anchored = false
	end
end

weld()
script:Remove()

2 comments

0

so which is last and the parts? Im taking a guess and going to say last is the base part, correct?

0

Thank you! I just switched out "last

This discussion is preserved as it was. New answers, comments, and votes are closed.