Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

cash loading script gives players money randomly???

Asked by 4 years ago
Edited 4 years ago

so in my game some people after rejoining have been getting large amounts of money. for example my friend had around 20 millions and after a rejoin he got 6 billions. he rejoined because of a massive lag. could it be because of the lag? here is the cash save/load script. i think its ok.

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("Cash24")
game.Players.PlayerAdded:Connect(function(plr)
    local cash = game.ServerStorage.MoneyStorage:WaitForChild(plr.Name)
    local success,err = pcall(function()
        cash.Value = ds1:GetAsync(plr.UserId) or 0
    end)
    if success then
        print("Your Data Has Been Loaded.")
    else
        print("Your Data Loading Has Failed.")
        warn(err)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local cash = game.ServerStorage.MoneyStorage:FindFirstChild(plr.Name)
    local success,err = pcall(function()
        ds1:SetAsync(plr.UserId, cash.Value)
    end)
    if success then
        print("Your Data Has Been Saved.")
    else
        print("We Got An Error While Saving Your Data.")
        warn(err)
    end
end)
2
whatever your problem is, it isn't the datastore, since it only STORES the value of the player's cash. The issue is probably in another script you use to reward players aprilsfooled 29 — 4y

Answer this question