Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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!

0
Hello sorry for the late comment but i tested it out and it worked! Thank you SO much! =) souf1000 6 — 3y
Ad

Answer this question