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

Help with Car Spawn Gui?

Asked by 10 years ago

So, i was making a car spawn gui, so if you click the TextButton it will spawn a car with you ontop of it.

local model = game.Lighting.NissanSkyline
local character = game.Players.LocalPlayer.Character
local Currecy = game.Players.LocalPlayer.leaderstats.CustomizationPoints
local Price = 0

function onClicked()
if Currency.Value >= Price then
Currency.Value = Currency.Value - Price
local a = model:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,10))
end
end
script.Parent.MouseButton1Click:connect(onClicked)

It works, but when it spawns, all the parts goes flying everywhere.

1 answer

Log in to vote
1
Answered by 4 years ago

Instead of using MoveTo, you can try to use :SetPrimaryPartCFrame()

Set a primary part for your model first.

local model = game.Lighting.NissanSkyline
local character = game.Players.LocalPlayer.Character
local Currecy = game.Players.LocalPlayer.leaderstats.CustomizationPoints
local Price = 0

function onClicked()
if Currency.Value >= Price then
Currency.Value = Currency.Value - Price
local a = model:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:SetPrimaryPartCFrame(character.Torso.CFrame * CFrame.new(0, 0, 10))
end
end
script.Parent.MouseButton1Click:connect(onClicked)

Also, make sure the parts of your car are welded together and not seperate.

Ad

Answer this question