Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this script in server script service not receiving the humanoids health?

Asked by 4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild("Humanoid")
        hum.HealthChanged:Connect(function()
            if hum.Health <= 50 then
                local info = TweenInfo.new(3)
                local tween = game:GetService("TweenService"):Create(hum,info,{Health=100})
            end
        end)    
    end)
end)

It only gets as far as to character added.

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I think you are misunderstanding this. When your character respawns, you start with 100 health and then it checks if the health is equal or lower than 50, but you have 100 health.

I think what you are trying to do is to make your health go back up when your health is below or equal to 50 right?

If so, you could use the Humanoid.HealthChanged event and check if the health is equal or below 50 each time it is fired and then do what you need to do.

0
Thanks! AcrylixDev 119 — 4y
0
It's not working. I'll edit the post according to the new script. AcrylixDev 119 — 4y
0
Wait, it's working, i forgot to do Tween:Play() AcrylixDev 119 — 4y
Ad

Answer this question