Hi. I have a car spawn gui but it's not working. I have a car but my problem is where do I put the cars and has my script got a error?

local P = script.Parent
local player = P.Parent.Parent
local index = 1

local vehicles = {
--  {NAME							, THUMBNAIL ID}
	{"2016 Land Rover Range Rover" 	, 386870784},
	{"2013 Honda Odyssey"  			, 380743419},
	{"2000 Honda S2000"  			, 378760604},
	{"2017 Audi Q7"					, 382485183},
	{"2004 Mazda RX-8"				, 347301191},
	{"2016 Honda Civic"				, 374694066},
	{"2017 Mercedes-AMG E43"		, 395747893},
	{"2012 Mitsubishi i-MiEV"		, 396341035},
	{"2016 Ford Focus RS"			, 348562255}
}

wait(0.5)
-- GUI vars
local bg = P.BG

-- Helper function
function SetInformation(index)
	bg.I.Image = "http://www.roblox.com/thumbs/asset.ashx?assetId="..vehicles[index][2].."&x=420&y=420"
	bg.T.Text = vehicles[index][1]
end

local locked = false
bg.S.MouseButton1Click:connect(function()
	if (locked) then return end
	locked = true
	local vehicleName = player.Name.."Car"
	if game.Workspace:FindFirstChild(player.Name.."Car") then
		game.Workspace[player.Name.."Car"]:Destroy()
	end
	if (not workspace:FindFirstChild(vehicleName)) then
		local model = game.ServerStorage.Vehicles:FindFirstChild(vehicles[index][1]):Clone()
		model.Name = vehicleName
		model.Parent = game.Workspace
		model:MakeJoints()
		model:MoveTo(player.Character.Torso.Position + Vector3.new(10, 0, 0))
		bg.Visible = false
	end	
	locked = false
end)

bg.B.MouseButton1Click:connect(function()
	index = index - 1
	if (index < 1) then index = #vehicles end
	SetInformation(index)
end)

bg.N.MouseButton1Click:connect(function()
	index = index + 1
	if (index > #vehicles) then index = 1 end
	SetInformation(index)
end)

SetInformation(index)

2 comments

0

Put the cars in ServerStorage. If it does not work try lighting.

0

Make a folder and name it vehicles and then put that folder in ServerStorage and within that folder put your cars in.