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.
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.