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)

01local trapPart = script.Parent
02 
03local function onPartTouch(otherPart)
04    local partParent = otherPart.Parent
05    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
06    if humanoid then
07        humanoid:TakeDamage(10)
08    end
09end
10 
11trapPart.Touched:Connect(onPartTouch)

medkit(Local script)

01local tool = script.Parent
02local player = game.Players.LocalPlayer
03repeat wait() until player.character
04local character = player.character
05local humanoid = character.Humanoid
06 
07 
08function health()
09    humanoid.Health = humanoid.Health + 30
10    tool.Enabled = false
11end
12 
13tool.Activated:Connect(health)
14 
15 
16tool.Equipped:Connect(function()
17    tool.Enabled = false
18end)

Starter Player health script(Local script)

1local player = game.Players.LocalPlayer
2repeat wait() until player.character
3character = player.character
4humanoid = character.Humanoid
5 
6humanoid.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