Please help me out guys how do you change the amount of health your character has in a game.Does an infinite value even exist? Changing it such that it is saved everytime the character respawns.
To do this, simply use math.huge!
Example in a server script:
wait(1) local plrs = game.Players:GetPlayers() --Replace with target player/character local chr = plrs[1].Character --Get player character --Set both maxhealth and health to an infinite value chr.Humanoid.MaxHealth = math.huge chr.Humanoid.Health = math.huge --Test the infinite values by repeatedly trying to damage the player. while true do chr.Humanoid:TakeDamage(100) print("DAMAGE TAKEN") wait(1) end
Don't use while loops, bad practice.
In a server script
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(Player) local ChangeHealth Player.CharacterAdded:Connect(function(Character) if ChangeHealth ~= nil then ChangeHealth:Disconnect() end local Humanoid = Character:WaitForChild("Humanoid") local MaxHealth = 2147483647 Humanoid.MaxHealth = MaxHealth ChangeHealth = Humanoid.HealthChanged:Connect(function() Humanoid.Health = MaxHealth end) end) end)
Locked by JesseSong
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?