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

How to check a datastore for a string?

Asked by 6 years ago

Alright, so I am trying to make a police database to check warrants and such on a car. I started with code getting everything set up but I got stuck on figuring out how to get a plate number to a new person that wasn't registered already. How would you check the datastore to make sure that a certain math is not their? Heres the code I got so far, please and thanks :)

local datastore = game:GetService("DataStoreService"):GetDataStore("LisencePlatesStorage")
local LisencePlate = "lisencePLATE"

game.Players.PlayerAdded:Connect(function(plr)
    local ID = LisencePlate.."-"..plr.UserId
    local savedData = nil

    local PlateNumber = Instance.new("StringValue")
    PlateNumber.Name = "PlateNumber"
    PlateNumber.Parent = plr

    pcall(function()
        savedData = datastore:GetAsync(ID)
    end)

    if savedData ~= nil then
        PlateNumber.Value = savedData
    else
        --math.random(removed because not decided on yet) 
        --area where stuck on
    end
end)
0
License Plates* DinozCreates 1070 — 6y
0
why did you make a variable for licenseplate? why not just do local whatever = "LisencePlate-"..plr.UserId. what are you trying to make the plate? is it strings and ints or just ints. if its ints then make PlateNumber an int not a string. DinozCreates 1070 — 6y
0
Its a string, its going to have both Letters and numbers cedricjake2006 2 — 6y

Answer this question