Hello, I'm trying to make a value called "hasVerified". It is set to 0 by default, but when I change it ingame, it does not save. Any idea why?
local dss = game:GetService("DataStoreService")
local vds = dss:GetDataStore("hasVerified")
game.Players.PlayerAdded:Connect(function(player)
local VerifiedData
local hasVerified = Instance.new("IntValue", player)
hasVerified.Name = "hasVerified"
local success, errormesssage = pcall(function()
VerifiedData = vds:GetAsync(player.UserId)
end)
if success then
if VerifiedData then
hasVerified.Value = VerifiedData
print(VerifiedData) -- Returns 0 instead of a different number
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
wait()
local success, errormessage = pcall(function()
vds:SetAsync(player.UserId, player.hasVerified.Value)
end)
end)

3 comments
Try printing.
Enable DataStore API?
turns out i need to use it in the actual game