Hello again,
OK i made this save system in my GameRounds script, that allows the players data to be saved (Rank,Exp) when they leave and come back that works perfectly, when a player gets points the system remembers the points it got and saves it. Once the player gets a specific amount of exp he/she is Ranked up.
Now the problem, when a player buys a store item it takes the currency like it suppose to, and as long as they are in that server, they can buy things till they run out of Exp, but once that player leaves, the system still remembers the old currency and did not remember the currency spent, and the player comes back with all there spent currency back in the leaderboard.
How do i make these lines of code i am about to provide save spent currency?
function playerEntered(player) local killer = Instance.new("ObjectValue", player) killer.Name = "Killer" local killed = Instance.new("StringValue", player) killed.Name = "Killed" local kills = Instance.new("NumberValue", player) kills.Name = "Kills" local class = Instance.new("StringValue", player) class.Name = "Class" class.Value = "Starter" player.Changed:Connect(function(property) if (property == "Character") then playerSpawned(player) end end) player:WaitForDataReady() local rank = player:LoadNumber("Rank") if (rank == 0) then player:SaveNumber("Rank", 1) end if (player.Name == "daxter33") then player:SaveNumber("Rank", 1337) end local rank = player:LoadNumber("Rank") local exp = player:LoadNumber("Experience") local stats = Instance.new("IntValue", player) stats.Name = "leaderstats" local rankValue = Instance.new("IntValue", stats) rankValue.Name = "Rank" rankValue.Value = rank local expValue = Instance.new("IntValue", stats) expValue.Name = "Exp" expValue.Value = exp end
this is where there was weapons but i removed as you can see at the bottom code it took the money and it saved what was took.
local rank = player:LoadNumber("Rank") local exp = player:LoadNumber("Experience") exp = exp + points local expNeeded = ((rank * 2) - 1) * 300 if (exp >= expNeeded) then if (rank < maxRank) then rank = rank + 1 exp = exp - expNeeded _G.updateFeed(player.Name.." has ranked up to rank "..rank, player.TeamColor.Color) _G.notify("You have ranked up to rank "..rank.."!", player, Color3.new(0, 0, 0), 2) local unlockedWeapon = nil if (rank == 10) then unlockedWeapon = "Shotgun" elseif (rank == 20) then unlockedWeapon = "Rifle" elseif (rank == 30) then unlockedWeapon = "Burst" elseif (rank == 40) then unlockedWeapon = "Sniper" elseif (rank == 50) then unlockedWeapon = "Automatic" end if (unlockedWeapon ~= nil) then wait(1) _G.notify("You have unlocked "..unlockedWeapon, player, Color3.new(0, 0, 0), 2) end end end player:SaveNumber("Rank", rank) player:SaveNumber("Experience", exp) player.leaderstats.Rank.Value = rank player.leaderstats.Exp.Value = exp end)) end)
thanks for helping!