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

Looking on how to set a variable that turns health pad on and off for certain amounts of time?

local healthBoost = script.Parent
local active = true

local function SteppedOn (otherPart)
	if active = true then
	parent = otherPart.Parent
	if game.Players:GetPlayerFromCharacter(parent) then
		parent.Humanoid.Health = parent.Humanoid.MaxHealth
		active = false
		wait(5)
		active = true
	end
end
healthBoost.Touched:connect(SteppedOn)

Here is the full code for the "healthBoost" thing I'm doing, and I'm trying to make it turn off for a specific amount of time after use, I've tried arranging it in so many ways, and it just won't work?? I need some help. It works fine without the active = true and active = false stuff, so can someone help me find out what I'm doing wrong?

1 answer

local healthBoost = script.Parent
local active = true

local function SteppedOn(otherPart)
    if active == true then --or it could be 'if active then' 
    parent = otherPart.Parent --Character
    if game.Players:GetPlayerFromCharacter(parent) then
        parent.Humanoid.Health = parent.Humanoid.MaxHealth
        active = false
        wait(5)
        active = true
    end
end
end -- WE LACK 1 END
healthBoost.Touched:connect(SteppedOn)

I thought it's something else .. But It's just a Heal Pad or button :)

4 comments

0

Setting value or something uses '='

0

Hm, still fails to work. :(

0

I just noticed .. you have 2 'if's .. and 1 function ... so you need to add 'end' for them .. We lack 1 'end' :)

0

oh! haha!

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