I followed alvin blox’s datastore tutorial, yet, I still have a error.
local warns = game:GetService("DataStoreService"):GetDataStore("WARNINGS")
game.Players.PlayerAdded:Connect(function(plr)
local admin = Instance.new("Folder", plr)
admin.Name = "Admin"
local warns = Instance.new("IntValue", admin)
warns.Name = "Warnings"
local warningData
local success, errormessage = pcall(function()
warningData = warns:GetAsync(plr.UserId.."-warn")
end)
if success then
warns.Value = warningData
else
warn("The warnings of "..plr.Name.." could not be loaded. Error: "..errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
warns:SetAsync(plr.UserId.."-warn",plr.Admin.Warnings.Value)
end)
if success then
print("Warnings of "..plr.Name.." saved.")
else
warn("The warnings of "..plr.Name.." could not be saved. Error: "..errormessage)
end
end)