Code:
local players = game:GetService("Players")
local function killHealth(player)
local hv = 100
local hum = player:FindFirstChildWhichIsA("Humanoid")
---i want the takeHealth for loop's value to return to 1 even after restoring 100 health
for takeHealth = 1, 100 do
hv = hv - 1
hum.Health = hv
print("turd")
wait(0.2)
if hum.Health == 100 then
hv = 100
print("health restored")
takeHealth = 1 --- my attempt at changing
end
end
end
local function charAdd(plr)
plr.CharacterAdded:Connect(killHealth)
end
players.PlayerAdded:Connect(charAdd)
I want the for loop to return to the first index when the humanoid’s health is restored to 100 (there is another script that restores the health, unrelated)
so it can actually still take the entire health of the humanoid after restoring the health instead
of ending at index 100 everytime.