Apparently it works only on R6, but I wanted to make it work on R15, but it spawn the car no where near the owner. Than the car spanwed near the R6 avatar.
So what can I fix this script to make R15 work? Thanks
local P = script.Parent
local player = P.Parent.Parent
local index = 1
local vehicles = game.ServerStorage.Vehicles:GetChildren()
wait(0.5)
-- GUI vars
local bg = P.BG
-- Helper function
function SetInformation(index)
bg.T.Text = vehicles[index].Name
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 = vehicles[index]: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)
