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

Why Am I unable to heal after taking damage?

Asked by 5 years ago
Edited 5 years ago

I'm having a hard time understanding whats happening. I made a medkit and a Damage Brick. The medkit works fine at healing on It's own, but when I take damage from the Brick I heal and It just regresses. I've spent almost 2 hours trying to find out whats wrong, any help?

Kill Brick(server script)

local trapPart = script.Parent

local function onPartTouch(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        humanoid:TakeDamage(10)
    end
end

trapPart.Touched:Connect(onPartTouch)

medkit(Local script)

local tool = script.Parent
local player = game.Players.LocalPlayer
repeat wait() until player.character
local character = player.character
local humanoid = character.Humanoid


function health()
    humanoid.Health = humanoid.Health + 30
    tool.Enabled = false
end

tool.Activated:Connect(health)


tool.Equipped:Connect(function()
    tool.Enabled = false
end)

Starter Player health script(Local script)

local player = game.Players.LocalPlayer
repeat wait() until player.character
character = player.character
humanoid = character.Humanoid

humanoid.Health = 10

The medkit ONLY stops working when you take damage from the brick.

0
This is most likely because you’ve set the health of the last set of code to 10. Try changing it to 100 and see. abcie 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You disabled the tool

At line 16 you made it if you equip the tool it sets Enabled to false which makes it you can't activate it

Try change false to true or just delete the Function entirely.

0
in medkit Luka_Gaming07 534 — 5y
0
Yes, if you disable it it won't work until it's enabled again. Time_URSS 146 — 5y
0
I don't lnow why, but neither of these work doomblade_66 55 — 5y
0
any errors? Luka_Gaming07 534 — 5y
Ad

Answer this question