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)

3 comments

0

License Plates*

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.

0

Its a string, its going to have both Letters and numbers