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)
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.
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.
if Level.Value >= 0 then
if Coins.Value >= LevelUpPrice.Value then
Level.Value += 1
Coins.Value -= LevelUpPrice.Value
UpdateLevelUpPrice()
end
end
end)