Helmet that increases hp

So i have this helmet model and im trying to make a script that when i click it will equip the helmet and the players hp will be increased.

All i have is for detecting that the tool is clicked,

function onActivation()
   print("Helmet Equippted")
end
1 Like

Hello, Your post doesn’t give much information about you troubles i was wondering if u can give the full code so i can see what im working with.

the first line was the only line that was cut off for some reason. Its fixed now. My troubles is that i dont know how to make the helmet appear and give hp when clicked.

You can change the MaxHealth and Health in Humanoid

So what you can do is im guessing there is a Clickdetector in this and you want it to give HP when clicked. So what you can do is:

local Helmet = script.Parent
local ClickDetector = game.workspace.Helmet.ClickDetector
local Amt = "Amt Of HP"

function OnActivation(player)
local char = player.Character
local Humanoid = Character.Humanoid
Humanoid.Health = Humanoid.Health + Amt
print("Helmet Equipped")
end

Helmet.ClickDetector.MouseClick:Connect(OnActivation)

i see how the script would work but how would i put it into a tool instead of a part in workspace

Tool consist of handle and other stuff. Habdle is basicly your workspace model. You can put the script inside your tool and detect if tool is equiped, we should increase Humanoid’s health.

local Helmet = script.Parent

local Amt = "50"

function OnActivation(player)
	local char = player.Character
	local Humanoid = Character.Humanoid
	Humanoid.Health = Humanoid.Health + Amt
	print("Helmet Equipped")
end

Helmet.Activated:Connect(onActivation)

This is as close as i could get but it seems to not work, when i click the print wont go through, could u help me with this

I am also trying to make it so it gives the hp when you click it when you are holding the tool did I do that correct?

Is Helmet is tool and not a model/part?

The helmet is a tool and not a part

local Helmet = script.Parent

local Amt = "50"

function OnActivation(player)
	local char = player.Character
	local Humanoid = Character.Humanoid
	Humanoid.Health += Amt
	print("Helmet Equipped")
end

Helmet.Activated:Connect(OnActivation)

it didn’t run because of a capitalization error

Well yeah i kinda just speed run it but you can fix it :slight_smile:

oops sorry i thought u where talking abt mine my fault

i tried the script you put but it didnt seem to work. I also put a few more prints above lines and lines and none would print.

1 Like

slender can you show more info about this helmet because im kind of just blind right now with this topic

if you mean by info, image that is the handle of the tool and when i have the tool out and click I want you to get extra hp on top of your normal hp. This is also the tool image

local Helmet = script.Parent

local Amt = 50

function OnActivation(player)
	local char = player.Character or player.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid")
	Humanoid.Health += Amt
	print("Helmet Equipped")
end

Helmet.Activated:Connect(OnActivation)

yea I realized I was trying to add with a string which is dumb

also I fixed anything else I could find

1 Like
local tool = script.Parent
local health = 200    -- You can set your value

local function onActive()
	local hum = script.Parent.Parent.Humanoid
	hum.MaxHealth = health
	hum.Health = health
end

tool.Activated:Connect(onActiv)

You can change Health variable’s value to amount of health you need.

Also this code was written very fast, so you can fix my typoes.

the script works but do u know how i could make it so it increases instead of changing the hp to 200 specificly

so basically can i make it so it adds 200 hp on top of normal roblox hp