In game i tried to change the value of the MoneyData. lets say from 5 to 1000. It would change the IntValue in game. but When i tried using the script it reads it has the same value of its original .
local DataList0 = {
MoneyData = 5;
RankData = "f";
};
function loadStarterData(Player)
local PlayerData = Instance.new("Folder", Player)
PlayerData.Name = "PlayerData"
for DataName, DataValue in pairs(DataList0) do
if typeof(DataValue) == "number" then
local MoneyData = Instance.new("IntValue",PlayerData)MoneyData.Name = "MoneyData"
elseif typeof(DataValue) == "string" then
local RankData = Instance.new("StringValue",PlayerData)RankData.Name = "RankData"
end
end
end
function saveData(Player)
local DataList = {}
for _, Data in pairs (Player.PlayerData:GetChildren()) do
if Data.Name == "MoneyData" then
DataList.MoneyData = Data.Value
print(Player.PlayerData.MoneyData.Value) -- I've changed the Value in Game yet it still only returns 5 no matter what i do.
else
if Data.Name == "RankData" then
DataList.RankData = Data.Value
end
end
end
local success, errormsg = pcall(function()
OneDataStorage:SetAsync("UserId:" .. Player.UserId, DataList)
end)
if success then
print("YAAYYYAYA :)")
else
warn("NOOOOOOOOOO ):")
end
end
