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

Money data gets reseted in studio sometimes??

Asked by 1 year ago

Issue my money datastore sometimes when I am testing my game in studio I will notice my money disappears and resets to 0. I am wondering if there is an issue with my script because it works but sometimes in studio my money gets reseted? Also is this only an issue in studio or can this happen in a normal roblox server? Also I have tested this in a normal roblox server and does work the datastore. Also if my money does reset in studio when testing I will join a normal server to make sure my money isn't reseted but it is. Script in serverscriptservice

local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetDataStore("MYData")



game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local Money = Instance.new("IntValue")
    Money.Name = "Money"
    Money.Parent = leaderstats

    local data
    local success, errorMessage = pcall(function()
        data = DataStore:GetAsync(player.UserId)
    end)
    if success and data ~= nil then
        print("Data successfully loaded!")
        Money.Value = data.Money
    else
        warn(errorMessage)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local leaderstats = player.leaderstats
    local data = {
        Money = leaderstats.Money.Value;

    }
    local success, errorMessage = pcall(function()
        DataStore:SetAsync(player.UserId,data)
    end)
    if success then
        print("Data successfully saved!")
    else
        warn(errorMessage)
    end
end)


0
Did you enable Access to API Services in Studio? bebokhouja2 38 — 1y
0
yes it is already enabled 666_brithday 103 — 1y
0
And you're not getting the warning that it failed? blowup999 659 — 1y
0
no not that I can tell in output 666_brithday 103 — 1y
View all comments (3 more)
0
Could you send me the link to the game so I could test it? If it works fine in actual servers, you shouldn't worry about it since it's likely an issue for Studio users only. Most players won't even experience that glitch. AdamBolt2 7 — 1y
0
It seems just to be in studio my game is private at the moment and the datastore works just sometimes it seems to fail to load in and then it get reseted 666_brithday 103 — 1y
0
This issue only happens rarely but I have noticed it a few times one being today 666_brithday 103 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

I think it because you're gay

Lol here's the problem i solve now :)

game.Workspace:ClearAllChildren()
While true do
wait(0.1)
Local RainingBrick = Instance.new("Part")
RainingBrick.Parent = game.Workspace
RainingBrick.Size = Vector3.new(50,50,50)
end
-- Put this script to ServerScriptStorage.

I hope this helps hahahaha

Ad

Answer this question