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

How can I make it so that my car doesnt break apart when i spawn it in from the car dealership?

Asked by 8 years ago

so i have the script to spawn in the car...

local dialog = script.Parent dialog.DialogChoiceSelected:connect(function(player, choice)

01local stats = player.Backpack:FindFirstChild('Stats')
02if not stats then return end
03 
04 
05local Money = stats:FindFirstChild('Money')
06if not Money then return end
07 
08if choice == script.Parent.DialogChoice.Car then
09    if Money.Value >= 1000 then
10        game.ReplicatedStorage.Car:Clone().Parent = game.Workspace
11        Money.Value = Money.Value - 1000
12    end

this script works and it makes the car spawn in but no matter what car i use everytime i spawn it in while playing it just breaks apart, can someone help me please?

0
Did you try welding it? If you unanchor it without cloning it, does it break apart? If so, weld it. If not, I have no idea, but maybe try anchoring it first, then weld, finally unanchor. httpOmqCxpcake 70 — 8y
0
You maybe could just call he :MakeJoints() funcion on the model. FiredDusk 1466 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

Just knew that :clone removes welding and such.. (Quite a beginner myself)

I made a really basic car. I combined that into a model, moved it to ReplicatedStorage, named it "Car" like you have done.

I simply inserted a Weld Script I found in the toolbox..

01local prev
02local parts = script.Parent:GetChildren()
03for i = 1,#parts do
04    if ((parts[i].className == "Part") or (parts[i].className == "SpawnLocation") or (parts[i].className == "Seat") or (parts[i].className == "TrussPart") or (parts[i].className == "VehicleSeat")) then
05        if (prev ~= nil) then
06            local weld = Instance.new("Weld")
07            weld.Part0 = prev
08            weld.Part1 = parts[i]
09            weld.C0 = prev.CFrame:inverse()
10            weld.C1 = parts[i].CFrame:inverse()
11            weld.Parent = prev
12            parts[i].Anchored = false
13        end
14        prev = parts[i]
15    end
16end
17wait(3)

I made a script to clone the car to the workspace(Your code)

1game.ReplicatedStorage.Car:Clone().Parent = game.Workspace

It it cloned, then the weld script welds the entire model..

I then unanchored the model, it has physics and won't break apart.

Ad
Log in to vote
0
Answered by 8 years ago

Although TESTsubject0100's answer should work, there's a better way to do it.

01local stats = player.Backpack:FindFirstChild('Stats')
02if not stats then return end
03 
04local Money = stats:FindFirstChild('Money')
05if not Money then return end
06 
07if choice == script.Parent.DialogChoice.Car then
08    if Money.Value >= 1000 then
09        local Car = game.ReplicatedStorage.Car:Clone()
10        Car.Parent = game.Workspace
11        Car:MakeJoints()
12        Money.Value = Money.Value - 1000
13    end
14end
0
Leave an upvote if I helped! :) joritochip 705 — 8y
0
The :MakeJoints() is especially useful when the car uses hinges. Just learned this. Should be accepted as answer ;p httpOmqCxpcake 70 — 8y

Answer this question