hey, I am trying to create an orbs currency system for a game. I didnt want to make a new script, so I just copy pasted from a game where I did the same thing except with gold instead of orbs. For some reason, the data just isnt storing. API access is on so that shouldnt be an issue. here is the script:
local DSS = game:GetService("DataStoreService")
local orbstore = DSS:GetDataStore("orbstore")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(plr)
local orbs = orbstore:GetAsync(player.UserId.. (" orbs"))
if orbs == nil then
local Orbs = player:SetAttribute("Orbs", 0)
else
local Orbs = player:SetAttribute("Orbs", orbstore:GetAsync(player.UserId.. (" orbs")))
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, err = pcall(function()
orbstore:SetAsync(player.UserId.. (" orbs"), player:GetAttribute("Orbs"))
end)
if success then
print("orbs saved")
elseif err then
print("orbs failed to save")
end
end)
thanks for any help !