Exp system value change and value assed (unsolved)

I have made a script for the xp system/level system that work but I want if player get more value than the limit to level then the extra value will go to the xp that needed to level up and if the player level up the value of xp that needed/required to level up will change or increase if the player level up more.

Value system (gui) >

local player = game.Players.LocalPlayer
local xp = player:WaitForChild("Exp")
local level = player:WaitForChild("levels")
local maxExp = 100

xp.Changed:Connect(function()
	if xp.Value >= maxExp then
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
		wait(0.5)
		xp.Value = 0
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
		level.Value = level.Value + 1
	else
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
	end
end)

script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)

xp text script >

local player = game.Players.LocalPlayer
local xp = player:WaitForChild("Exp")
local maxExp = 1853970

script.Parent.Text = xp.Value..' / 100'

xp.Changed:Connect(function()
	script.Parent.Text = xp.Value..' / 100'
end)

add this

xp.Changed:Connect(function()
	if xp.Value >= maxExp then
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
		wait(0.5)
		xp.Value = 0
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
		level.Value = level.Value + 1
     maxExp = maxExp*2 (or any amount you want to increase it)
	else
		script.Parent.Size = UDim2.new(xp.Value/maxExp,0,1,0)
	end
end)
1 Like

ok the value change work the only thing right now is the value assed and the xp text of the value that change

do this

local player = game.Players.LocalPlayer
local xp = player:WaitForChild("Exp")
local maxExp = player:WaitForChild("MaxExp")

script.Parent.Text = xp.Value..' / 100'

xp.Changed:Connect(function()
	script.Parent.Text = xp.Value..' / '..maxExp
end)

do I need to make the maxExp a IntValue in the leaderstats script

Yes, and change your script references accordingly

	    local maxExp = Instance.new("IntValue", player)
	    maxExp.Name = 'maxExp'
	    maxExp.Value = 0

do i need the value

Yes, with all the Instance values you need to add the .Value

Because your intvalue is an object, just like 3d parts in your explorer, you dont change the object, you change its parameter, in this case .Value

ok I have put the value

maxExp = maxExp*2 or (275)

but when i join the game the gui become like this
Screenshot 2022-03-24 205230
and when i level up the gui become like this
Screenshot 2022-03-24 205230
the text doesn’t change to the value text that i have put

i have fix the gui problem but the only this is the txt amout required and the value assed