[HELP] trying to create random 4 letters for plate

if you remove Length, String, Keys, and the for loop then the script works fine. But with these changes on I get greenlit error :frowning:

AddEventHandler('boatshop:GetIdentifierBoat', function()
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local L = #player - 4
    local L1 = #player - 3
    local L2 = #player - 2
    local L3 = #player - 1
	local Length = 4
	local String = ""
	local Keys = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}

	        for i = 1,Length do
            String = String..Keys[math.random(1,#Keys)]
            end
        
    local plate = String .. player[L] .. player[L1] .. player[L2] .. player[L3]
    plate = string.upper(plate)
    TriggerClientEvent("boatshop:f_GetIdentifier_boat", source, plate)
  end)
end)

can someone tell me what I am doing wrong please?

What you can try is to use this:

local letters = {{β€œA”},{β€œB”},{β€œC”},{β€œD”},{β€œE”},{β€œF”},{β€œG”},{β€œH”},{β€œI”},{β€œJ”},{β€œK”},{β€œL”},{β€œM”},{β€œN”},{β€œO”},{β€œP”},{β€œQ”},{β€œR”},{β€œS”},{β€œT”},{β€œU”},{β€œV”},{β€œW”},{β€œX”},{β€œY”},{β€œZ”}}
local plate = math.random(10, 99)…’’…letters[math.random(1, 26)]…’’…letters[math.random(1, 26)]…’’…letters[math.random(1, 26)]…’’…math.random(100, 999)

example Output: 14ADE935

1 Like

Hi, can you help me? I need generate random plates like this: UCV 345

3 random letters, space, 3 random numbers

What Code can I use, and where I would put it. Thx in advance.