|
| 25 Jan 2017 04:28 PM |
game.Players.PlayerAdded:connect(function(plr) plr.StarterGear:WaitForChild("SaveFolder") local spins = plr.StarterGear.SaveFolder.Spins.Value local level = plr.StarterGear.SaveFolder.Level.Value local maxXP = plr.StarterGear.SaveFolder.MaxXP.Value local currentXP = plr.StarterGear.SaveFolder.CurrentXP.Value local level = plr.StarterGear.SaveFolder.Level.Value
while maxXP == currentXP.Value do level = level +1 end end)
it is supposed to give you one more level when you reach the max xp but its not working at all. And it shows no error...
Love breeds sacrifice... which in turn breeds hatred. Then you can know pain. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2017 04:46 PM |
Lots of problems: currentXP isn't a reference to the player's current xp, it's just a number of the xp the player has when that line of code runs.
level is defined twice.
There is no wait in the while loop, so it could crash the game.
You don't do anything to reset the xp or increase max xp after you give the player another level, so you'll get infinite levels.
This should work
game.Players.PlayerAdded:connect(function(plr) plr.StarterGear:WaitForChild("SaveFolder") local spins = plr.StarterGear.SaveFolder.Spins
local level = plr.StarterGear.SaveFolder.Level local maxXP = plr.StarterGear.SaveFolder.MaxXP local currentXP = plr.StarterGear.SaveFolder.CurrentXP
currentXP.Changed:connect(function() if currentXP.Value >= maxXP.Value then currentXP.Value = currentXP.Value - maxXP.Value level.Value = level.Value + 1 end end)
end end) |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2017 04:47 PM |
| Why are you using StarterGear, everything in that is cloned to the Backpack so use that instead |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2017 04:48 PM |
| lol, forgot about that, you probably want to change that as well. |
|
|
| Report Abuse |
|
|