Data Change Help

Hi there, I’ve retrieved a system that stores data for a registration plate and roofcode for emergency services, there is one issue. I cannot change the data. I can change the values but it doesn’t make a difference at all for the text. I’ve attempted making guis that would be able to do this but that was just an effort that wasn’t required.

I’m not really a scripter so I’m not sure what I would need to include in the thread to assist you, however, I’ll include the scripts that are included in the system even though if they aren’t relevant.


–[[
3/19/20
newwil
DataStore/Leaderstats
–]]

local DataStoreService = game:GetService(“DataStoreService”)

local playerData = DataStoreService:GetDataStore(“playerData”)

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “PlayerStatistics”
leaderstats.Parent = player

local registration = Instance.new("StringValue")
registration.Name = "Registration"
registration.Value = "EMPTY"
registration.Parent = leaderstats

local roofcode = Instance.new("StringValue")
roofcode.Name = "Roofcode"
roofcode.Value = "EMPTY"
roofcode.Parent = leaderstats

local registrationdata
local codedata

local success, errormessage = pcall(function()
	registrationdata = playerData:GetAsync(player.UserId.."-registration1") 
	codedata = playerData:GetAsync(player.UserId.."-roofcode")
end)


if success then 

	registration.Value = registrationdata

	roofcode.Value = codedata
	if registration.Value == "EMPTY" then
		local Alphabet = {"F"}
		local NumberPlate = (Alphabet[math.random(1,#Alphabet)]..math.random(1,9)..math.random(1,9)..math.random(1,9)..Alphabet[math.random(1,#Alphabet)])
		player["PlayerStatistics"].Registration.Value = NumberPlate
	end
	if roofcode.Value == "EMPTY" then
		local Alphabet = {"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 VehicleCode = (Alphabet[math.random(1,#Alphabet)]..Alphabet[math.random(1,#Alphabet)]..Alphabet[math.random(1,#Alphabet)])
		player["PlayerStatistics"].Roofcode.Value = VehicleCode
	end
else
	print("Error while getting your data")
	warn(errormessage)
end

end)

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall(function()
	playerData:SetAsync(player.UserId.."-registration1", player.PlayerStatistics.Registration.Value)
	playerData:SetAsync(player.UserId.."-roofcode", player.PlayerStatistics.Roofcode.Value)
end)

if success then
	print("Data successfully saved!")
	print(player.PlayerStatistics.Registration.Value)
	print(player.PlayerStatistics.Roofcode.Value)
else
	print("There was an error while saving the data")
	warn(errormessage)
end

end)


script.Parent.Touched:Connect(function(Player)
wait(0.3)
local statsystem = script.Parent.Parent.STATSYSTEM
local RP = statsystem.RearPlate.SGUI.Identifier
local FP = statsystem.FrontPlate.SGUI.Identifier
local callsign = script.Parent.Parent.STATSYSTEM:GetChildren()
local PlrNam = Player.Parent.Name
local PlayerInPlayers = game.Players:FindFirstChild(PlrNam)
local REGTEXT1 = PlayerInPlayers:FindFirstChild(“PlayerStatistics”)
local REGTEXT = REGTEXT1.Registration
local CSTEXT = REGTEXT1.Roofcode
local texty = REGTEXT.Value
local roofcode = CSTEXT.Value
FP.Text = texty
RP.Text = texty
for i,v in pairs(callsign) do
if v.Name == “Callsign” then
v.SurfaceGui.TextLabel.Text = roofcode
end
end
wait(0.5)
script:Destroy()
end)


That is all the scripts, any help would be amazingly appreciated.

To add on, all I’m really looking for is something I can enter into the command bar just to execute a command, all I need to do is change the data for people.

Thank you,
Joe

are there any errors on the dev console? press fn + f9

there is no errors, all im looking for is a simple command that can change the data and everybody can see