My data store isn't working for some reason. API services are turned on. It's really weird because if I do something in studio it saves, but it won't save in player, but It will load in player.
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CreditSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local Credits = Instance.new("IntValue",player)
Credits.Name = "Credits"
Credits.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Credits.Value)
Credits.Changed:connect(function()
ds:SetAsync(player.UserId, Credits.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.Credits.Value)
end)

1 comment
I recommend wrapping anything that has to do with data store in a pcall, as it occasionally errors. You cannot stop these errors, so you should wrap it into a pcall.