So I have a levelling system that I've coded, with working experience and such. I have one problem.
The maximum experience you can gain until you level up is 100, and I want to reward a user 200 exp for completing an action, but when I do so, the number goes over and it basically breaks the script, and says 200/100 (200 being experience gained, 100 being experience needed to level up). I know this is a long shot, but I would really appreciate any help. If anyone has experience with levelling systems, please contact me. :>
--by killerkill29
main = script.Parent
player = game.Players.LocalPlayer
levelled = false
local checklevel = coroutine.wrap(function()
while wait() do -- what happens when exp == gained exp
if main:WaitForChild("total").total1.Value == main:WaitForChild("have").have1.Value then
main:WaitForChild("level").level1.Value = main:WaitForChild("level").level1.Value + 1
main:WaitForChild("cover").levelnumber.Text = ("LEVEL " .. main.level.level1.Value)
main:WaitForChild("have").have1.Value = 0
levelled = true
print(player.Name .. " levelled up!")
wait(1.4)
end
end
end)
local level = coroutine.wrap(function()
while wait() do -- when the person levels up
if levelled == true then
main:WaitForChild("levelup").Text = ("You are now level " .. main.level.level1.Value .. "!")
char = game.Players.LocalPlayer.Character
char.Head:WaitForChild("level").frame.Text = ("LEVEL " .. main.level.level1.Value)
main.levelup.TextTransparency = 0.8
main.levelup.TextStrokeTransparency = 0.8
wait(0.2)
main.levelup.TextTransparency = 0.6
main.levelup.TextStrokeTransparency = 0.6
wait(0.2)
main.levelup.TextTransparency = 0.4
main.levelup.TextStrokeTransparency = 0.4
wait(0.2)
main.levelup.TextTransparency = 0.2
main.levelup.TextStrokeTransparency = 0.2
wait(0.2)
main.levelup.TextTransparency = 0.4
main.levelup.TextStrokeTransparency = 0.4
wait(0.2)
main.levelup.TextTransparency = 0.6
main.levelup.TextStrokeTransparency = 0.6
wait(0.2)
main.levelup.TextTransparency = 0.8
main.levelup.TextStrokeTransparency = 0.8
wait(0.2)
main.levelup.TextTransparency = 1
main.levelup.TextStrokeTransparency = 1
levelled = false
end
end
end)
local levelfind = coroutine.wrap(function()
while wait() do --what happens when a person reaches a certain level
char = game.Players.LocalPlayer.Character
if main.level.level1.Value == 10 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(0, 255, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 20 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(170, 255, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 30 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(0, 255, 255)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 40 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(0, 0, 255)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(255, 255, 255)
elseif main.level.level1.Value == 50 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(255, 255, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 60 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(255, 170, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 70 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(255, 0, 255)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 80 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(255, 0, 127)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 90 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(255, 0, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value == 100 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(170, 0, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(0, 0, 0)
elseif main.level.level1.Value <= 9 then
char.Head:WaitForChild("level").frame.TextColor3 = Color3.new(0, 0, 0)
char.Head:WaitForChild("level").frame.TextStrokeColor3 = Color3.new(255, 255, 255)
end
end
end)
level()
checklevel()
levelfind()
The top is the code of the main system. The GUI has seperate values, each with their own script. Hope this is enough.

3 comments
Include the script on this post! We can only help if you give us something to help with.
Yes, post the code, please.
Posted the main code. Hope this helps :)