Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Am I unable to heal after taking damage?

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.

1 comment

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.

1 answer

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.

4 comments

0

in medkit

0

Yes, if you disable it it won't work until it's enabled again.

0

I don't lnow why, but neither of these work

0

any errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.