local Data = game:GetService("DataStoreService"):GetDataStore("carxda123 12a a1a23123")
local PlatesData = game:GetService("DataStoreService"):GetDataStore("car1aa1112a3123")
local letters = {"a", "b", "c","d", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
local numbers = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}
local usid = "GLOBAL";
_G["GamePlates"] = {}
function saveplates()
if _G["GamePlates"][1] then
print('yep yep potato chip')
local save = _G["GamePlates"]
PlatesData:SetAsync(usid, save)
end
end
function GetPlates()
local data = PlatesData:GetAsync(usid)
if data then
_G["GamePlates"] = data
else
_G["GamePlates"] = {}
end
end
function SetPlateOnModel(PlayerName, InstanceVehicle)
print("giving")
local car
if InstanceVehicle then
car = InstanceVehicle
else
car = workspace:FindFirstChild(PlayerName.."'s Car")
end
local Plate = car.Model.Body:FindFirstChild("Plate")
GetPlates()
print('allgood...')
if Plate then
print('plate here...')
local VehiclePlate = nil
for i,v in ipairs(_G["GamePlates"]) do
print(v[1]..v[2]..v[3])
if v[2] == PlayerName and v[3] == InstanceVehicle.Name then
VehiclePlate = v[1]
end
end
print(VehiclePlate)
if VehiclePlate ~= nil then
print('found plate')
Plate.Plate1.SurfaceGui.TextLabel.Text = VehiclePlate
Plate.Plate1.SurfaceGui.TextLabel.Text = VehiclePlate
elseif VehiclePlate == nil then
print('nil')
if InstanceVehicle then
InstanceVehicle:Destroy()
end
game.ReplicatedStorage.EventsFolder.Notifications:FireClient(game.Players[PlayerName], "There was an error while spawning car.", 7)
end
end
end
function GivePlate(plr, VehicleModel)
local plate
local yepyep = false
repeat
plate = string.upper(letters[math.random(1, #letters)])..string.upper(letters[math.random(1, #letters)])..string.upper(letters[math.random(1, #letters)]).." "..numbers[math.random(1, #numbers)]..numbers[math.random(1, #numbers)]..numbers[math.random(1, #numbers)]
yepyep = true
for i,v in ipairs(_G["GamePlates"]) do
if v.Plate == plate then
yepyep = false
end
end
wait()
until yepyep == true
wait()
if yepyep == true then
GetPlates()
table.insert(_G["GamePlates"],{Plate = plate ,Owner = plr.Name, Vehiclemodel = VehicleModel})
saveplates()
end
end
game:GetService("ReplicatedStorage").BuyCar.OnServerEvent:Connect(function(Player, Item)
if Item then
local ItemPrice = AllItems[Item]
if not Data:GetAsync(Player.UserId.."-"..Item) then
if Player['leaderstats']['Wallet'].Value >= ItemPrice then
Data:SetAsync(Player.UserId.."-"..Item, {Color="Black"})
GivePlate(Player, Item)
end
end
end
end)
GetPlates()
game:GetService("ReplicatedStorage").SpawnCar.OnServerInvoke = function(player,NameOfCar)
if Data:GetAsync(player.UserId.."-"..NameOfCar) then
print('okboomr')
local vehicleName = player.Name .. "'s Car"
SetPlateOnModel(player.Name, car)
end
end
Hello! So this is my code, basically, i removed some stuff to make it look more easy to understand, so, it should give the plates, but it looks like _G[“GamePlates”] It’s empty, I can’t find the error, it’s printing, but it’s not changing car plate, no errors, I don’t know why… help!! Looks like when it saves, if it was empty or when I call GetPlates() and try to print _G[“GamePlates”][1] it says nil… any idea? I’ve beentrying to fix this all day
OUTPUT:
https://gyazo.com/5e16fd6cd20cca3ca451772919f63f34