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

Help With Another Car Spawning Script?

Asked by
Scootakip 299 Moderation Voter
8 years ago
local car1 = game.Lighting.Car
local car2 = game.Lighting.Car2
local character = game.Players.LocalPlayer.Character
local ifcar = game.Players.LocalPlayer.Car
local gui = script.Parent
local mycar = game.Players.LocalPlayer.MyCar
gui.Text = "Get Car"

local carchoose = script.Parent.Parent.CarChoose
local carchoose1 = script.Parent.Parent.CarChoose.Car1Choose
local carchoose2 = script.Parent.Parent.CarChoose.Car2Choose
carchoose.Visible = false

local destroy = script.Parent.Parent.Des


function mycar1()
if ifcar.Value== 0 then
a = car1:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,10))
ifcar.Value = 1

if destroy.MouseButton1Click then
    a:Destroy()
end
end
end


function mycar2()
if ifcar.Value== 0 then
a = car2:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,10))
ifcar.Value = 1

if destroy.MouseButton1Click then
    a:Destroy()
end
end
end




function onClicked()
if carchoose.Visible == false then
    carchoose.Visible = true
elseif carchoose.Visible == true then
    carchoose.Visible = false
    end
end

script.Parent.MouseButton1Click:connect(onClicked)
carchoose1.MouseButton1Click:connect(mycar1)
carchoose2.MouseButton1Click:connect(mycar2)

I need help fixing this script. I have a gui that opens another gui, and when you click that other gui it spawns a car. But I also have a third gui that's supposed to get rid of the car when you click it, however that's not working. With this version of the script the a:Destroy() seems to break the script and won't even let the car spawn anymore. Can someone please help me with this.

Answer this question