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

Problem with a cart, its falling apart everytime i playtest it. Anyone can help please?

Okay i was wondering if anyone can help me out with this because i have no clue.

So i am trying to create a cart ride game, but i want to make a different cart, so i copied one of the carts from the toolbox, and i tried to make the cart look different.

Follow the link so u can see how the cart looks.

================== https://ibb.co/zPGYg1q

But when i am done and im trying to test it out in the game, it falls apart.

================== https://ibb.co/qjtVvpM

Can anyone explain to me why this happens? Please!

1 answer

✓ Accepted answer

Group the body into a model, then add a script on the model, then put this:

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

local prev
local unanchor = {}

function search ( n )
 n = n or script.Parent
	for i, v in pairs(n:getChildren()) do
		if v:IsA("BasePart") and not v.Name:find("Wheel") then
			if prev then
	Weld(v, prev)
	prev = v
	unanchor[#unanchor + 0] = v
	else
	prev = v
	unanchor[#unanchor + 0] = v
	   end
	  end
	search(v)
	 end
	end

function unanchormodel(m)
	local g = m:GetChildren()
	for i = 1, #g do
		if (g[i]:IsA("BasePart")) then
			g[i].Anchored = false
		elseif (g[i]:IsA("Model")) then
			unanchormodel(g[i])
		end
	end
end



search()
wait()
unanchormodel(script.Parent)

Accept the answer if it worked!

1 comment

0

Hello sorry for the late comment but i tested it out and it worked! Thank you SO much! =)

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