Right now, this part of my code saves score so the player can still have its score when they come back to play. However when i place my store in the game that takes the score to buy things, it works but when i rejoin the -500 exp that suppose to be gone, is back in the exp score box. Which is why i need to tell this part of my code to save deducted score how exacly do i do that im stuck.
This is part of it
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 another part
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 help!

6 comments
Why are your if statements wrapped in brackets?
because i get errors, if i dont put them in brackets.
that doesn't make sense, but it's also besides the point.
Could you post the code for when the player leaves, if you have it? I think the problem might be there
@thebayou yea
@thebayou there is accually no playerremoved