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

Welding script that welds a model to a chassis makes the parts from the model at the wrong position?

i made a weld script, that welds the body to the chassis. When im not playing the game (not playing) it looks fine. But if i play the game, some parts are at the wrong place. Whats wrong with it?

not running:

https://cdn.discordapp.com/attachments/438417429564227585/503561157240553502/ unknown.png (remove all the spaces)

when running:

https://cdn.discordapp.com/attachments/438417429564227585/503561565983735823/ unknown.png (remove all the spaces)

script:

local parts = script.Parent:GetChildren()

for i = 1, #parts do
	if parts[i]:IsA("BasePart") then
		local w = Instance.new("Weld")
		w.Part0 = script.Parent.Parent.VehicleSeat
		w.Part1 = parts[i]
		w.C0 = script.Parent.Parent.VehicleSeat.CFrame:Inverse()
		w.C1 = parts[i].CFrame:inverse()
		w.Parent = script.Parent.Parent.VehicleSeat
	end 
end

thank you!

2 comments

0

what chassis do you use? did you make it yourself or it is ss6, or a-chassis

0

i made it

1 answer

function Weld(x,y)
	local W = Instance.new("Weld")
	W.Part0 = x
	W.Part1 = y
	local CJ = CFrame.new(x.Position)
	local C0 = x.CFrame:inverse()*CJ
	local C1 = y.CFrame:inverse()*CJ
	W.C0 = C0
	W.C1 = C1
	W.Parent = x
end

function Get(A)
	if A:IsA("BasePart") then
		Weld(script.Parent.Handle, A)
		A.Anchored = false
	else
		local C = A:GetChildren()
		for i=1, #C do
		Get(C[i])
		end
	end
end

I am using that weld code whenever I want to weld something. You just simply Get(script.Parent).

1 comment

0

the script only welds the body, it doesnt weld it to the vehicle seat tho, making it fall out of the body.

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