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

Chassis keeps falling apart when regenerated?

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

1 comment

0

At least you have somebody who is kind that helped you..

1 answer

✓ Accepted answer

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)

5 comments

0

Never mind, I fixed it. Thank you so much!

0

You are welcome :)

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()'

0

I might try that. Thanks for suggestion, Bunny. I like rabbits. Just saying.

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