I was trying to make a level up system, where if you reach 100 EXP then you get an extra level, but it doesn't work.
Script
if player.leaderstats.Level.EXP.Value >= player.leaderstats.Level.Max then player.leaderstats.Level.EXP.Value = 0 player.leaderstats.Level.Value = player.leaderstats.Level +1 end
Please help.
If Level.Max
is a NumberValue or another ValueBase you need to check the Value of this Instance. Like that: Level.Max.Value
Try this
if (player.leaderstats.Level.EXP.Value >= player.leaderstats.Level.Max.Value) then player.leaderstats.Level.EXP.Value = 0 player.leaderstats.Level.Value += 1 end
Hope this help, to more questions put bellow on commentaries.
ok, so this is not that hard to do. There is something called "Changed" this event happens whenver the number value is changed, you can find the artical here:
https://developer.roblox.com/en-us/api-reference/event/NumberValue/changed
script:
--====================these are just the leveling requirments============= game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local exp = Instance.new("IntValue", player) exp.Name = "Exp" local max = Instance.new("IntValue", player) max.Name = "Max" max.Value = 100 local level = Instance.new("IntValue", leaderstats) level.Name = "Level" level.Value = 1 --============================Below is leveling detector=================== exp.Changed:Connect(function(value) -- changed function print("expValue Changed") -- prints whenever you get more exp if value == max.Value then --if the exp is bigger than the max exp exp.Value = 0 -- resetting the exp to 0 after leveled up level.Value += 1 -- adding one more level max.Value += 50 --every time you level up, you will need 50 more exp to level up again print("YAY U LEVELED UP!!") end end) end)