How Do I Make If You Level Up The Health And The Max Health Increases

I Was Wondering How Do I Make If You Level Up And The Health And The Max Health Increases
This Is The Script

local player = game.Players.LocalPlayer
local level = player:WaitForChild("Level")
local current = level:WaitForChild("Current")
local max = level:WaitForChild("Max")

-- UI-related variables.
local gui = script.Parent
local exterior = gui:WaitForChild("Exterior")
local label = exterior:WaitForChild("Label")
local exp = exterior:WaitForChild("Exp")
local bar = exterior:WaitForChild("Bar")

-- Change stats upon join.

label.Text = "Level "..level.Value
exp.Text = current.Value.."/"..max.Value.." EXP"
bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)

level.Changed:Connect(function(val)
	label.Text = "Level "..level.Value
	exp.Text = current.Value.."/"..max.Value.." EXP"
	bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)
	game.Workspace["LevelUp"]:Play()
end)

current.Changed:Connect(function(val)
	exp.Text = current.Value.."/"..max.Value.." EXP"
	bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)	
end)

This Is The EXP Gui
Screenshot_65
And This Is The Health Gui
Screenshot_66
Please Let me Know-How

1 Like

Make a server script and make it this

local MaxHealthRate = 50 -- how much the max health is upgraded per level
game.Players.PlayerAdded:Connect(function(Plr)
	Plr.CharacterAdded:Connect(function(Char)
		local Level = Plr:WaitForChild("Level")
		local StartHum = Char:FindFirstChildWhichIsA("Humanoid") or Char:WaitForChild("Humanoid")
		if StartHum then
			StartHum.MaxHealth += MaxHealthRate
			StartHum.Health = Hum.MaxHealth
		end
		Level.Changed:Connect(function()
			local Hum = Char:FindFirstChildWhichIsA("Humanoid")
			if Hum then
				Hum.MaxHealth += MaxHealthRate
				Hum.Health = StartHum.MaxHealth
			end
		end)
	end)
	
end)
1 Like

Are You Sure?
It’s Gonna Give Me A Warning

1 Like

Can you show the full code? That isn’t really helpful. Also those things are really misleading sometimes. Just test it out

@piratehammer

1 Like

It Gave Me A Error
Screenshot_71
I Thought It Was A Warning

Can you show the code plz. Plz

1 Like

Fine

Change the Hum to StartHum. That’ll fix it

1 Like

The Health Starts With 100 Not 150
Screenshot_73

Change it to this


local MaxHealthRate = 50 -- how much the max health is upgraded per level
game.Players.PlayerAdded:Connect(function(Plr)
	Plr.CharacterAdded:Connect(function(Char)
		local Level = Plr:WaitForChild("Level")
		local StartHum = Char:FindFirstChildWhichIsA("Humanoid") or Char:WaitForChild("Humanoid")
		if StartHum and Level.Value > 1 then
			StartHum.MaxHealth += MaxHealthRate * Level.Value
			StartHum.Health = Hum.MaxHealth
		end
		Level.Changed:Connect(function()
			local Hum = Char:FindFirstChildWhichIsA("Humanoid")
			if Hum then
				Hum.MaxHealth += MaxHealthRate
				Hum.Health = StartHum.MaxHealth
			end
		end)
	end)
	
end)

@piratehammer

1 Like