Theres no error in the output but it just doesn’t heal
Cilent code:
local player = game.Players.LocalPlayer
player.Character.Humanoid.HealthChanged:Connect(function()
local Humanoid = player.Character.Humanoid
wait(7.5)
game.ReplicatedStorage.Heal:FireServer()
end)
Server Code:
local maxhp = 100
game.ReplicatedStorage.Heal.OnServerEvent:Connect(function(plr)
local Humanoid = plr.Character.Humanoid
repeat
Humanoid.Health += 2
wait(0.5)
until Humanoid.Health >= maxhp
end)
Basically it’s a client-server problem. The player’s health is most likely changing on the client, but it hasn’t changed on the server. I’d recommend whatever is draining the player’s health, it should be done on the server rather than the client to make this script work. You can even eliminate the remote event and local script all together. None the less, all your code is working fine and doing everything it says it’s doing.
i mean you can use a script instead local just put a script in the starterCharacter then write in this:
local Humanoid = script.Parent.Humanoid
local currentHealth = Humanoid.Health
Humanoid.HealthChanged:Connect(function(health)
if health < currentHealth then
repeat
Humanoid.Health += 2
wait(0.5)
until Humanoid.Health >= 100
end
end)