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

Why does inverse work in this weld script?

So im confused. how does Inverse work in this? wouldn't inverse make the position completely off?

local prev
for i, parts in pairs(script.Parent:GetChildren()) do
	if parts.className == "Part" then
		if (prev ~= nil) then
			local weld = Instance.new("Weld")
			weld.Part0 = prev
			weld.Part1 = parts
			print(weld.C0)
			weld.C0 = prev.CFrame:inverse()
			print(weld.C0)
			weld.C1 = parts.CFrame:inverse()
			weld.Parent = prev
			parts.Anchored = false
		end
		prev = parts
	end
end
wait(3)

3 comments

0

inverse is simply flipping the cframe. Its the opposite of the cframe

0

ik but why is this relevant here?

0

I'm not sure about this one, because normally inverse is used to convert things to local space.

1 answer

It's because it sets both C0 and C1. Weld CFrame is determined sort of in this way:

WeldCFrame = C0 * C1:inverse() (C0 might be the inversed one, not sure, but you get the idea)

So the bit in your code:

weld.C0 = prev.CFrame:inverse()
weld.C1 = parts.CFrame:inverse()

Is equal to:

weld.C0 = prev.CFrame:inverse() * parts.CFrame

Not sure why would you use the first case, as it might be bit more confusing and relatively slower than using the 'classic' way.

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