for example, if i change the maxhealth to 150, the player's health will go to 150. when their health goes below 100, the maxhealth goes back to 100. this works fine only the first time. every time after that, the maxhealth changes back to 100 after i change it
local lp = game.Players.LocalPlayer local char = lp.Character or lp.CharacterAdded:wait() local ad = script.Parent local frame = script.Parent local humanoid = char:WaitForChild("Humanoid") humanoid.HealthChanged:Connect(function() repeat wait(1) if humanoid.MaxHealth > 100 then frame.Visible = true end until frame.Visible == true local health = humanoid.Health - 100 ad.Size = UDim2.new(health/100,0,1,0) if humanoid.MaxHealth > 100 then if humanoid.Health < 100 then frame.Visible = false humanoid.MaxHealth = 100 end end end)
try this script
local health = game.Players.LocalPlayer.Character.Health if health == 100 then --Anything you want if health is 100 elseif health < 100 then health = 100 end
I think this is what you mean?
local lp = game.Players.LocalPlayer local char = lp.Character or lp.CharacterAdded:wait() local ad = script.Parent local frame = script.Parent local humanoid = char:WaitForChild("Humanoid") humanoid.HealthChanged:Connect(function() if humanoid.MaxHealth > 100 then frame.Visible = true -- Set health to 100 if we go below 100 if humanoid.Health < 100 then humanoid.MaxHealth = 100 frame.Visible = false end else -- Doesn't let you set MaxHealth below 100 humanoid.MaxHealth = 100 end humanoid.Health = humanoid.MaxHealth end)