Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago
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 :)

0
Setting value or something uses '=' User#17685 0 — 6y
0
Hm, still fails to work. :( RandomMildChicken 11 — 6y
0
I just noticed .. you have 2 'if's .. and 1 function ... so you need to add 'end' for them .. We lack 1 'end' :) User#17685 0 — 6y
0
oh! haha! RandomMildChicken 11 — 6y
Ad

Answer this question