Why i cant level up more then 1 time? (check pinned video)

why i cant level up more then 1 time
(dont look at price to next level up in level up gui)
2024-02-21 19-27-56.mp4 - Google Drive - there is a video so you can understand what i mean
level up script:

local RS = game:GetService("ReplicatedStorage")
local Event = RS.Remotes.LevelUpEvent

local LevelUpPrice = script.LevelUpPrice

Event.OnServerEvent:Connect(function(plr)
	local leaderstats = plr:WaitForChild("leaderstats")
	local Coins = leaderstats.Coins
	local Level = leaderstats.Level
	
	local function UpdateLevelUpPrice()
		if Level.Value >= 1 then
			LevelUpPrice.Value = (100 * (1.5^Level.Value))
		end
	end
	
	if Level.Value == 0 then
		if Coins.Value >= LevelUpPrice.Value then
			Level.Value += 1
			Coins.Value -= LevelUpPrice.Value
			UpdateLevelUpPrice()
		elseif Level.Value >= 1 then
			if Coins.Value >= LevelUpPrice.Value then
				Level.Value += 1
				Coins.Value -= LevelUpPrice.Value
				UpdateLevelUpPrice()
			end
		end
	end
end)
1 Like
if Level.Value == 0 then
		if Coins.Value >= LevelUpPrice.Value then
			Level.Value += 1
			Coins.Value -= LevelUpPrice.Value
			UpdateLevelUpPrice()
		elseif Level.Value >= 1 then
			if Coins.Value >= LevelUpPrice.Value then
				Level.Value += 1
				Coins.Value -= LevelUpPrice.Value
				UpdateLevelUpPrice()
			end
		end
	end

This part of your script is not correct, your if statements just don’t make any sense.
The rest of your script is fine.

1 Like

emm bro ur code is the same with mine

:man_facepalming:
Yeah I never changed it, I just told you what’s wrong with it so you can fix it yourself and learn from your mistakes to become a better programmer.

2 Likes

if i remove if statements script will be completely broken

1 Like

You shouldn’t remove them.
I recommend that you try learning if statements with a simple and small function first.
It’s very easy to learn it shouldn’t take more than a few minutes and after learning the basics you will be perfectly able to fix this beginner mistake yourself.

I’m sorry if that sounds rude, I don’t mean to be.
I really believe this would help you in becoming a better programmer.

3 Likes

ok thanks anyway im just tired of giving up so many times after having no answer in devforum

pls just one time give me a solution i really dont understand

YAY I FOUND
ITS

	if Level.Value >= 0 then
		if Coins.Value >= LevelUpPrice.Value then
			Level.Value += 1
			Coins.Value -= LevelUpPrice.Value
			UpdateLevelUpPrice()
		end
	end
end)
1 Like

bro im such an idiot : p
hahahahahahahah

1 Like

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