RBXLegacy-src/11911558.xml

43 lines
1.4 KiB
XML

<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<External>null</External>
<External>nil</External>
<Item class="Script" referent="RBX0">
<Properties>
<bool name="Disabled">false</bool>
<Content name="LinkedSource"><null></null></Content>
<string name="Name">Health</string>
<ProtectedString name="Source">--Responsible for regening a player&apos;s humanoid&apos;s health
-- declarations
local Figure = script.Parent
local Head = Figure:WaitForChild(&quot;Head&quot;)
local Humanoid = Figure:WaitForChild(&quot;Humanoid&quot;)
local regening = false
-- regeneration
function regenHealth()
&#9;if regening then return end
&#9;regening = true
&#9;
&#9;while Humanoid.Health &lt; Humanoid.MaxHealth do
&#9;&#9;local s = wait(1)
&#9;&#9;local health = Humanoid.Health
&#9;&#9;if health &gt; 0 and health &lt; Humanoid.MaxHealth then
&#9;&#9;&#9;local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
&#9;&#9;&#9;health = health + newHealthDelta
&#9;&#9;&#9;Humanoid.Health = math.min(health,Humanoid.MaxHealth)
&#9;&#9;end
&#9;end
&#9;
&#9;if Humanoid.Health &gt; Humanoid.MaxHealth then
&#9;&#9;Humanoid.Health = Humanoid.MaxHealth
&#9;end
&#9;
&#9;regening = false
end
Humanoid.HealthChanged:connect(regenHealth)
</ProtectedString>
</Properties>
</Item>
</roblox>