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

How do I make a brick that when you touch it, your Max Health changes until you die?

So I want to make a brick that when you click it, it changes your Max Health until you die. But I can't find out the code to do it! Can anybody help me?

4 comments

0

By doing it yourself.

0

bruh

3

You can't expect people to do the work for you. Help yourself. I'd be glad to help if you posted your code, but the presence of code is nil here. See your way out.

0

ah, i see you want me to do it all by myself. i see it, im not mad. i understand. so what ur saying is that i should fiddle around with the scripts

2 answers

Roblox has an object called "ClickDetector" that you can put in any brick to be able to tell when someone clicks it. Then you have to make a function that will fire whenever that happens.

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(plr)

end)

As you can see, I put plr as one of the placement holders for the function, that's because when someone activates it, that player automatically gets put in the function as a variable.

Then you can put whatever you want to happen in that function

ClickDetector.MouseClick:Connect(function(plr)

	health = 150

	local char = plr.Character
	local humanoid = char.Humanoid

	humanoid.MaxHealth = health

end)
db = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent.Humanoid then
        if db == true then
            db = false
            hit.Parent.Humanoid.MaxHealth = 200 -- change to what their health will be
            hit.Parent.Humanoid.Health = 200
            wait(2)
            db = true
        end
    end
end)

This should work. If this helped please accept this answer.

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