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

How do I add to the players health?

Asked by 2 years ago

this is my script to try but I cant find out how to add to the players health?

local UserInputService = game:GetService("UserInputService")
local debounce = false
local heal = 50
UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.R then
        local name = game.Players.LocalPlayer
        local player = game.Workspace:FindFirstChild(name.Name)
        player.Humanoid.MaxHealth = 125
        player.Humanoid.Health + heal
    end)
0
try setting player.Humanoid.Health to itself like player.Humanoid.Health = player.Humanoid.Health + heal Mario684 4 — 2y
0
Instead of "player.Humanoid.Health + heal" you can do "player.Humanoid.Health += heal" appxritixn 2235 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

simple use "+="

local UserInputService = game:GetService("UserInputService")
local debounce = false
local heal = 50
UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.R then
        local name = game.Players.LocalPlayer
        local player = game.Workspace:FindFirstChild(name.Name)
        player.Humanoid.MaxHealth = 125
        player.Humanoid.Health += heal
    end)
Ad

Answer this question