Level system add points on level up

hello guys!

i made a leveling system but…
i want to add 1 point when the player levels up.
since there is a Wait() innit i cant just add it from there it will add a ton of points wich i dont want.
the value i want to upgrade is in the folder savedstats and its called points
here is the script:

local player = script.Parent.Parent
local xp = player:WaitForChild("savedstats"):FindFirstChild("XP")
local Level = player:WaitForChild("leaderstats"):FindFirstChild("Level")
local points = player:WaitForChild("savedstats"):FindFirstChild("Points")
local remote = script.RemoteEvent
while wait(0.01) do
	if xp.Value >= 0 and xp.Value <= 100 then
		Level.Value = 1
	elseif xp.Value >= 100 and xp.Value <= 200 then
		Level.Value = 2
	elseif xp.Value >= 200 and xp.Value <= 300 then
		Level.Value = 3
	elseif xp.Value >= 300 and xp.Value <= 400 then
		Level.Value = 4
	elseif xp.Value >= 400 and xp.Value <= 500 then
		Level.Value = 5
	elseif xp.Value >= 500 and xp.Value <= 600 then
		Level.Value = 6
	elseif xp.Value >= 600 and xp.Value <= 700 then
		Level.Value = 7
	elseif xp.Value >= 700 and xp.Value <= 800 then
		Level.Value = 8
	elseif xp.Value >= 800 and xp.Value <= 900 then
		Level.Value = 9
	elseif xp.Value >= 900 and xp.Value <= 1000 then
		Level.Value = 10
	elseif xp.Value >= 1000 and xp.Value <= 1100 then
		Level.Value = 11
	elseif xp.Value >= 1100 and xp.Value <= 1200 then
		Level.Value = 12
	elseif xp.Value >= 1200 and xp.Value <= 1300 then
		Level.Value = 13
	elseif xp.Value >= 1300 and xp.Value <= 1400 then
		Level.Value = 14
	elseif xp.Value >= 1400 and xp.Value <= 1500 then
		Level.Value = 15
	elseif xp.Value >= 1500 and xp.Value <= 1600 then
		Level.Value = 16
	elseif xp.Value >= 1600 and xp.Value <= 1700 then
		Level.Value = 17
	elseif xp.Value >= 1700 and xp.Value <= 1800 then
		Level.Value = 18
	elseif xp.Value >= 1800 and xp.Value <= 1900 then
		Level.Value = 19
	elseif xp.Value >= 1900 and xp.Value <= 2000 then
		Level.Value = 20
	elseif xp.Value >= 2000 and xp.Value <= 2100 then
		Level.Value = 21
	elseif xp.Value >= 2100 and xp.Value <= 2200 then
		Level.Value = 22
	elseif xp.Value >= 2200 and xp.Value <= 2300 then
		Level.Value = 23
	elseif xp.Value >= 2300 and xp.Value <= 2400 then
		Level.Value = 24
	elseif xp.Value >= 2400 and xp.Value <= 2500 then
		Level.Value = 25
	elseif xp.Value >= 2500 and xp.Value <= 2600 then
		Level.Value = 26
	elseif xp.Value >= 2600 and xp.Value <= 2700 then
		Level.Value = 27
	elseif xp.Value >= 2700 and xp.Value <= 2800 then
		Level.Value = 28
	elseif xp.Value >= 2800 and xp.Value <= 2900 then
		Level.Value = 29
	elseif xp.Value >= 3000 and xp.Value <= 3100 then
		Level.Value = 30
	elseif xp.Value >= 3100 and xp.Value <= 3200 then
		Level.Value = 31
	elseif xp.Value >= 3200 and xp.Value <= 3300 then
		Level.Value = 32
	elseif xp.Value >= 3300 and xp.Value <= 3400 then
		Level.Value = 33
	elseif xp.Value >= 3400 and xp.Value <= 3500 then
		Level.Value = 34
	elseif xp.Value >= 3500 and xp.Value <= 3600 then
		Level.Value = 35
	elseif xp.Value >= 3600 and xp.Value <= 3700 then
		Level.Value = 36
	elseif xp.Value >= 3700 and xp.Value <= 3800 then
		Level.Value = 37
	elseif xp.Value >= 3800 and xp.Value <= 3900 then
		Level.Value = 38
	elseif xp.Value >= 3900 and xp.Value <= 4000 then
		Level.Value = 39
	elseif xp.Value >= 4000 and xp.Value <= 4100 then
		Level.Value = 40
	elseif xp.Value >= 4100 and xp.Value <= 4200 then
		Level.Value = 41
	elseif xp.Value >= 4200 and xp.Value <= 4300 then
		Level.Value = 42
	elseif xp.Value >= 4300 and xp.Value <= 4400 then
		Level.Value = 43
	elseif xp.Value >= 4400 and xp.Value <= 4500 then
		Level.Value = 44
	elseif xp.Value >= 4500 and xp.Value <= 4600 then
		Level.Value = 45
	elseif xp.Value >= 4600 and xp.Value <= 4700 then
		Level.Value = 46
	elseif xp.Value >= 4700 and xp.Value <= 4800 then
		Level.Value = 47
	elseif xp.Value >= 4800 and xp.Value <= 4900 then
		Level.Value = 48
	elseif xp.Value >= 4900 and xp.Value <= 5000 then
		Level.Value = 49
	elseif xp.Value >= 5000 and xp.Value <= 5100 then
		Level.Value = 50
	elseif xp.Value >= 5100 and xp.Value <= 5200 then
		Level.Value = 51
	elseif xp.Value >= 5200 and xp.Value <= 5300 then
		Level.Value = 52
	elseif xp.Value >= 5300 and xp.Value <= 5400 then
		Level.Value = 53
	elseif xp.Value >= 5400 and xp.Value <= 5500 then
		Level.Value = 54
	elseif xp.Value >= 5500 and xp.Value <= 5600 then
		Level.Value = 55
	elseif xp.Value >= 5600 and xp.Value <= 5700 then
		Level.Value = 56
	elseif xp.Value >= 5700 and xp.Value <= 5800 then
		Level.Value = 57
	elseif xp.Value >= 5800 and xp.Value <= 5900 then
		Level.Value = 58
	elseif xp.Value >= 5900 and xp.Value <= 6000 then
		Level.Value = 59
	elseif xp.Value >= 6000 and xp.Value <= 6100 then
		Level.Value = 60
	elseif xp.Value >= 6100 and xp.Value <= 6200 then
		Level.Value = 61
	elseif xp.Value >= 6200 and xp.Value <= 6300 then
		Level.Value = 62
	elseif xp.Value >= 6300 and xp.Value <= 6400 then
		Level.Value = 63
	elseif xp.Value >= 6400 and xp.Value <= 6500 then
		Level.Value = 64
	elseif xp.Value >= 6500 and xp.Value <= 6600 then
		Level.Value = 65
	elseif xp.Value >= 6600 and xp.Value <= 6700 then
		Level.Value = 66
	elseif xp.Value >= 6700 and xp.Value <= 6800 then
		Level.Value = 67
	elseif xp.Value >= 6800 and xp.Value <= 6900 then
		Level.Value = 68
	elseif xp.Value >= 6900 and xp.Value <= 7000 then
		Level.Value = 69
	elseif xp.Value >= 7000 and xp.Value <= 7100 then
		Level.Value = 70
	elseif xp.Value >= 7100 and xp.Value <= 7200 then
		Level.Value = 71
	elseif xp.Value >= 7200 and xp.Value <= 7300 then
		Level.Value = 72
	elseif xp.Value >= 7300 and xp.Value <= 7400 then
		Level.Value = 73
	elseif xp.Value >= 7400 and xp.Value <= 7500 then
		Level.Value = 74
	elseif xp.Value >= 7500 and xp.Value <= 7600 then
		Level.Value = 75
	elseif xp.Value >= 7600 and xp.Value <= 7700 then
		Level.Value = 76
	elseif xp.Value >= 7700 and xp.Value <= 8000 then
		Level.Value = 77
	elseif xp.Value >= 8000 and xp.Value <= 8500 then
		Level.Value = 78
	elseif xp.Value >= 8500 and xp.Value <= 9000 then
		Level.Value = 79
	elseif xp.Value >= 9000 and xp.Value <= 9500 then
		Level.Value = 80
	elseif xp.Value >= 9500 and xp.Value <= 10000 then
		Level.Value = 81
	elseif xp.Value >= 10000 and xp.Value <= 10750 then
		Level.Value = 82
	elseif xp.Value >= 10750 and xp.Value <= 11250 then
		Level.Value = 83
	elseif xp.Value >= 11250 and xp.Value <= 12000 then
		Level.Value = 84
	elseif xp.Value >= 12000 and xp.Value <= 12750 then
		Level.Value = 85
	elseif xp.Value >= 12750 and xp.Value <= 13500 then
		Level.Value = 86
	elseif xp.Value >= 13500 and xp.Value <= 14000 then
		Level.Value = 87
	elseif xp.Value >= 14000 and xp.Value <= 14750 then
		Level.Value = 88
	elseif xp.Value >= 14750 and xp.Value <= 15250 then
		Level.Value = 89
	elseif xp.Value >= 15250 and xp.Value <= 16050 then
		Level.Value = 90
	elseif xp.Value >= 16050 and xp.Value <= 17000 then
		Level.Value = 91
	elseif xp.Value >= 17000 and xp.Value <= 18000 then
		Level.Value = 92
	elseif xp.Value >= 18000 and xp.Value <= 19000 then
		Level.Value = 93
	elseif xp.Value >= 19000 and xp.Value <= 20000 then
		Level.Value = 94
	elseif xp.Value >= 20000 and xp.Value <= 21000 then
		Level.Value = 95
	elseif xp.Value >= 21000 and xp.Value <= 22000 then
		Level.Value = 96
	elseif xp.Value >= 22000 and xp.Value <= 23000 then
		Level.Value = 97
	elseif xp.Value >= 23000 and xp.Value <= 24000 then
		Level.Value = 98
	elseif xp.Value >= 24000 and xp.Value <= 25000 then
		Level.Value = 99
	elseif xp.Value >= 25000 and xp.Value <= 100000 then
		Level.Value = 100
	elseif xp.Value >= 100000 and xp.Value <= 999999999999 then
		Level.Value = 1000
	end
end
while wait(0.1) do
	Level.changed:Connect(function()
	remote:FireClient()
end)
end


please help me achieve this!

TY

2 Likes

What do you mean point?
Do you mean XP?

1 Like

no like stat points its a value in “savedstats”

1 Like

I feel like you should probably use the % operator for the level system so you don’t need so many elseifs.

2 Likes

I don’t get what your problem is.

If your stats are not updating, it could be because the script is a local script. Instead of updating the level value in the local script, send a remote event to the sever side and update it in the sever script.

If you are trying to add a point every time the players level up, you can do points.Value += 1 every time the level updates.

1 Like

wait let me try this… i didnt do this yet :sweat_smile:

1 Like

hi, i just looked at your code and just wanted to say this, i want to scream into my pillow. thank you for listening.

4 Likes

lmao i hace spaghetti code fr fr

1 Like

didnt work :confused: sadly bruh (fwwfwqq charactertes)

1 Like

is this in a local script, if it is, try updating the values on the sever side.

1 Like

its not a local script its just a normal script

1 Like

it could be that it is in a while loop, like you said in the post. Instead, only activate it when the level is change by replacing while wait() do with xp.Changed:Connect(function().

But I currently still don’t know what the full problem actually is. Lmk whats happening and what you want to accomplish.

2 Likes

let me try this and what i want to accomplish is that when the level value goes 1 up the point value = +1

1 Like

This damn near had me in tears :sob:

2 Likes

it is spaghetti code ik :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face: :crying_cat_face:

1 Like

Hya, I see you want to achieve a level system, but the way you are doing it, it’s not the best.

First of all, you can create another instance called MaxExperience and set a default value for the experience needed to first level up

Second, you can track when the experience changes using Experience.Changed or Experience:GetPropertyChangedSignal(“Value”)

Check if the Experience.Value >= MaxExperience.Value

Here is a demo

Experience.Changed:Connect(function(Value)
if Experience.Value >= MaxExperience.Value then
Experience.Value = Experience.Value - MaxExperience.Value
MaxExperience.Value = MaxExperience.Value + 100

Points += 1
Level += 1

end
end)

Hope this helped you.

3 Likes

what…why are there 99 else-if statements :sob:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.