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

Chassis keeps falling apart when regenerated?

Asked by 6 years ago
Edited 6 years ago

So I figured how to make realistic throttles, but now when I regen my chassis, well, it all falls apart. I have a weld script in but it just keeps falling apart.

The code in the regen is:

local Engine = script.Parent.Parent["Model"]
local CloneTrain = Engine:clone()
Button = script.Parent.Parent.WCSpawn

function spawnTrain()
    if Button.BrickColor == BrickColor.new(104) then
    local Model = CloneTrain:Clone()--Clones the backup so the script doesn't break
    Model:MakeJoints() --Makes it so the model doesn't fall apart.
        Model.Parent = game.Workspace --Puts the model into the game
    Button.BrickColor = BrickColor.new(26)
    wait(45)
    Button.BrickColor = BrickColor.new(104)
    end
end



script.Parent.ClickDetector.MouseClick:connect(spawnTrain)

Here are images:

Normal: https://gyazo.com/4f701374e6fed020144e29873ad3f97a

Regened: https://gyazo.com/9894b23d8f52114d3bc851fc618fbd26

0
At least you have somebody who is kind that helped you.. RobloxEmotes 3 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

All I did was switch the lines 7 and 8 positions, it should be working now:

local Engine = script.Parent.Parent["Model"]
local CloneTrain = Engine:clone()
Button = script.Parent.Parent.WCSpawn

function spawnTrain()
    if Button.BrickColor == BrickColor.new(104) then
    local Model = CloneTrain:Clone()--Clones the backup so the script doesn't break
    Model.Parent = game.Workspace --Puts the model into the game
    Model:MakeJoints() --Makes it so the model doesn't fall apart.
    Button.BrickColor = BrickColor.new(26)
    wait(45)
    Button.BrickColor = BrickColor.new(104)
    end
end


script.Parent.ClickDetector.MouseClick:connect(spawnTrain)
0
Never mind, I fixed it. Thank you so much! CarlPlandog 20 — 6y
0
You are welcome :) Le_Teapots 913 — 6y
0
You beat me to it! I had a similar problem but just one line of code will stop it from falling apart. 'spawnVehicle:MakeJoints()' BunnyFilms1 297 — 6y
0
I might try that. Thanks for suggestion, Bunny. I like rabbits. Just saying. CarlPlandog 20 — 6y
Ad

Answer this question