The script below is being inserted into a Player's Character through a Remote Event.
wait(0.1)
local character = script.Parent
local timeRemaining = 16
repeat
character.Humanoid.Health = character.Humanoid.Health + 2.5
wait(0.2)
timeRemaining = timeRemaining - 1
print("Healing time remain: " .. timeRemaining)
until timeRemaining == 0
script:Destroy()
It's a simple script, and does not seem to have any issues running as it prints 16 times, every 0.2 seconds. However there is no effect on the Health. It's not healing the player by 2.5 every 0.2 x 16.
Does anyone know the issue? I have also tried using a while true loop, simply doing character.Humanoid.Health + 30, etc. with no luck.
Thank you, excA
I'm attaching the code responsible for moving the above script to Character too:
~~~~~~~~~~~~~~~~~
local RemoteEvents = game:GetService("ReplicatedStorage").Events
local HealOthers = RemoteEvents.HealOthers
local function onHealOthers(player)
print(player.Name, "heals up others")
local HealScript = script.HealScript:Clone()
local character = player.Character
HealScript.Parent = character
HealScript.Disabled = false
for i, v in pairs(game.Players:GetPlayers()) do
if (v.Character.HumanoidRootPart.Position - character.HumanoidRootPart.Position).magnitude <= (15) then
if v.Team == player.Team then
print(v.Name.." has been healed up")
HealScript.Parent = v.Character
HealScript.Disabled = false
end
end
end
end
HealOthers.OnServerEvent:Connect(onHealOthers)
~~~~~~~~~~~~~~~~~
It also works, as the script is copied and parented to the Character.
```edit#2
Having edited the code to this:
~~~~~~~~~~~~~~~~~
wait(0.1)
local timeRemaining = 16
local character = script.Parent
repeat
character.Humanoid.Health = character.Humanoid.Health + 2.5
print(""..script.Parent.Name.." has been healed +2.5, his health is now: "..character.Humanoid.Health.." HP")
wait(0.2)
timeRemaining = timeRemaining - 1
print("Healing time remain: " .. timeRemaining)
until timeRemaining == 0
script:Destroy()
~~~~~~~~~~~~~~~~~
The code prints:
excellentAnarchy has been healed +2.5, his health is now: 100 HP
Even though, my HP is not 100, where have I gone wrong?

2 comments
what does it print
It prints "print("Healing time remain: " .. timeRemaining)" every 0.2, therefore the code works.