Alright so the exp bar works but the only thing I'm trying to do on the if statement is to also change the size of the bar back to 0 when you level up which I attempted to do here. I'm also trying to change amount of exp needed to level up x2 etc. Is it possible to be helped?

https://gyazo.com/191e3b28fa186a3cf43b5adab3ec89ae

-- In a local script

local player = game.Players.LocalPlayer
local main = script.Parent.Parent
local bar = script.Parent


player.EXP.Changed:connect(function()
	local overlay = bar.Overlay
	local ammount = bar.Ammount
	local level = player:WaitForChild('Level').Value
	local exp = player:WaitForChild('EXP').Value
	overlay:TweenSize(UDim2.new(exp/100, 0, 0 ,20), 'Out', 'Quad', 1)
	print(overlay.Size)
	ammount.Text = exp..'/100'
	main.CurrentLevel.Text = level..''
	if ammount.Text == '100/100' then
		print('Working')
		overlay.Size = UDim2.new(0, 0, 0, 20)
		player.Level.Value = player.Level.Value + 1
		print(overlay.Size)
	end
end)

1 comment

0

What if the experience of the player goes over 100/100 (lets say because you add 20 to 88). The script only runs if it is exactly equal to 100