So I have this code here:
local MaxExp = 2
local CurrentExp = script.Parent.Exp.Value
local CurrentLevel = script.Parent.Level.Value
local IncreaseIncrement = 0.15/MaxExp
local ExpBarSize = CurrentExp*IncreaseIncrement
function CheckStats()
while true do
wait(.1)
if CurrentExp==MaxExp then
CurrentLevel = CurrentLevel + 1
MaxExp = MaxExp + 2
CurrentExp = 0
script.Parent.ExperienceAmount:TweenSize(UDim2.new(0, 0, 0.025, 0), "In", "Quad", .1, false, nil)
end
script.Parent.LevelText.Text = ("Level "..CurrentLevel)
script.Parent.ExperienceText.Text = (CurrentExp.."/"..MaxExp)
script.Parent.ExperienceAmount:TweenSize(UDim2.new(ExpBarSize, 0, 0.025, 0), "Out", "Quad", .5, false, nil)
end
end
CheckStats()
Basically, all I wanted to do was create a simple exp bar script, but I ended up spending way too much time just trying to figure out why this won't work. The problem is that Roblox Studio seems to think that nothing is wrong, and I can't see what is wrong either. However, once, I tried putting all of the variables into the while loop, and it worked, but the level number wouldn't go up and was kind of flickering, and the exp wouldn't reset to 0. I tried to expand on that, but I couldn't get anywhere besides back to where I started. I am just so lost on this right now, and I would really love some help please :) |