I don't get it: why is this error showing up?

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)

I believe the problem is, you’re getting async of a IntValue not a datastore.

That’s the point? I want to get the saved value and put it in the warnings value.

You have 2 things set as “warns”

1 is:

local warns = game:GetService("DataStoreService"):GetDataStore("WARNINGS")

2 is:

local warns = Instance.new("IntValue", admin) 
1 Like

Ohhh right. Thanks for pointing it out.

1 Like