I’ve been working on a datastore script over the past few days, and I ran into a weird error. When trying to save a value, for some reason my script will only read the information from the last save, meaning that despite the value I’m trying to save has changed, it will always read an old value. I have seen other posts like this where the developer made the variable for the value before it had changed, but my variable is always being created after the saving function has started, so I have no clue why this is happening.
The value in properties:
That same value being saved:
Code:
workspace.saveBtn.save.Triggered:Connect(function(Player : Player)
local Foldername = ("p" .. Player.UserId)
local tokens = workspace:WaitForChild("PlayerValues"):WaitForChild(Foldername):WaitForChild("dataValue").Value
print(tokens)
local info = {
Tokens = tokens;
id = tostring(Player.UserId);
message = "Hello, there.";
}
print(info)
playerStuff[Player.UserId].Data.FrenzyTokens = info.Tokens
playerStuff[Player.UserId]:SaveData(info)
print("Saved! You have " .. info.Tokens .. " Tokens.")
end)
If this is a little confusing, I can try to elaborate. It’s confusing me too, lol