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

How do I fix my AFK script, so that when people turn it on, they can't be hurt?

Asked by
Mycran 7
4 years ago

Despite adding a forcefield, you are still able to lose health, apparently.

local force
local on = false

script.Parent.MouseButton1Down:connect(function()
    local player = script.Parent.Parent.Parent.Parent

    on = not on

    if on then
        player.Character.Humanoid.WalkSpeed = 0
        force = Instance.new("ForceField",player.Character)
    else
        force:Destroy()
        player.Character.Humanoid.WalkSpeed = 32
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

Try saving the amount of health they have when they turn on AFK. Then, when the health changes/repeatedly change their health to the amount that was saved. You will probably want to attach a value to a player/character and store the health in there so that you can change the health later on (also, you might want to put it outside of the connect and use a loop to check if on is true and then change the health.

0
dumb it down for me i am scripting boomer Mycran 7 — 4y
0
Set a variable with the player's health in it, and as long as they are AFK their health should always be set to that variable. MacaylaMarvelous81 15 — 4y
Ad

Answer this question