so i have the script to spawn in the car...
local dialog = script.Parent dialog.DialogChoiceSelected:connect(function(player, choice)
local stats = player.Backpack:FindFirstChild('Stats') if not stats then return end local Money = stats:FindFirstChild('Money') if not Money then return end if choice == script.Parent.DialogChoice.Car then if Money.Value >= 1000 then game.ReplicatedStorage.Car:Clone().Parent = game.Workspace Money.Value = Money.Value - 1000 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?
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..
local prev local parts = script.Parent:GetChildren() for i = 1,#parts do 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 if (prev ~= nil) then local weld = Instance.new("Weld") weld.Part0 = prev weld.Part1 = parts[i] weld.C0 = prev.CFrame:inverse() weld.C1 = parts[i].CFrame:inverse() weld.Parent = prev parts[i].Anchored = false end prev = parts[i] end end wait(3)
I made a script to clone the car to the workspace(Your code)
game.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.
Although TESTsubject0100's answer should work, there's a better way to do it.
local stats = player.Backpack:FindFirstChild('Stats') if not stats then return end local Money = stats:FindFirstChild('Money') if not Money then return end if choice == script.Parent.DialogChoice.Car then if Money.Value >= 1000 then local Car = game.ReplicatedStorage.Car:Clone() Car.Parent = game.Workspace Car:MakeJoints() Money.Value = Money.Value - 1000 end end