I’m working on a cash system and every time for every user, it says the data is 100.
I have a command that will change the data up or down, I try this and the value goes to the correct value + the amount I added.
On top of this, it says the queue is full even though I only sent one request?
Code
Code:
local DataStoreService = game:GetService("DataStoreService")
local frCashData = DataStoreService:GetDataStore("frCash")
local starterCash = 50
local groupid = 8131674
local rankid = 9
game.Players.PlayerAdded:Connect(function(player)
local success, frCash = pcall(function()
return frCashData:GetAsync(player)
end)
if frCash == nil then
local success, err = pcall(function()
frCashData:SetAsync(player, starterCash)
end)
if success then
print("DataSet")
game.Players:WaitForChild(player.Name).PlayerGui:WaitForChild("FresheUi").User.Currency.Text = tostring(starterCash).. " frCash"
end
else
print("Found Data! Data: ".. frCash)
game.Players:WaitForChild(player.Name).PlayerGui:WaitForChild("FresheUi").User.Currency.Text = tostring(frCash).. " frCash"
end
-- Edit frCash
player.Chatted:Connect(function(msg)
if player:GetRankInGroup(groupid) >= rankid or player.Name == "rivertropic" then
if string.sub(msg, 0,7) == "frCash " or string.sub(msg, 0,7) == "frcash " then
local nameend = string.find(msg, " ",8)
if nameend ~= nil then
local name = string.sub(msg, 8, nameend-1)
local client = nil
for _,v in pairs(game.Players:GetPlayers()) do
if string.lower(name) == string.lower(string.sub(v.Name,0,string.len(name))) then
client = v.Name
local success, newfrCash = pcall(function()
return frCashData:IncrementAsync(name, string.sub(msg,nameend+1))
end)
frCashData:SetAsync(name, newfrCash)
if success then
local success, frCash = pcall(function()
return frCashData:GetAsync(name)
end)
if success then
game.Players:WaitForChild(name).PlayerGui:WaitForChild("FresheUi").User.Currency.Text = tostring(frCash).. " frCash"
game.Players:WaitForChild(name).PlayerGui:WaitForChild("FresheUi").Events.pendNotif:FireAllClients("frCash modified", player.Name.." has just modified your frCash - ".. string.sub(msg,nameend+1).. " frCash")
end
end
end
end
end
end
if string.sub(msg, 0,6) == "Getfr " or string.sub(msg, 0,6) == "getfr " then
local nameend = string.find(msg, " ",7)
if nameend ~= nil then
local name = string.sub(msg, 7, nameend-1)
local client = nil
for _,v in pairs(game.Players:GetPlayers()) do
if string.lower(name) == string.lower(string.sub(v.Name,0,string.len(name))) then
client = v.Name
local success, frCash = pcall(function()
return frCashData:GetAsync(name)
end)
if success then
game.Players:WaitForChild(player.Name).PlayerGui:WaitForChild("FresheUi").User.Currency.Text = tostring(frCash).. " frCash"
game.Players:WaitForChild(player.Name).PlayerGui:WaitForChild("FresheUi").Events.pendNotif:FireAllClients("frCash balance", name.."'s frCash balance is "..frCash.." frCash")
end
end
end
end
end
end
end)
end)