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

Changing a boolian in the player?

So I have the boolian called "AFK" in the player (game.Players.AFK) and I'm trying to make it change on click, it's a local script. I don't know what's wrong and nothing is producing errors.

local plr = game.Players.LocalPlayer

function Down()
if plr.AFK.Value == true then
    plr.AFK.Value = true
script.Parent.Text = "Back"
else
    script.Parent.Text = "Go afk"
plr.AFK.Value = false
end
end

script.Parent.MouseButton1Click:connect(Down)

1 answer

✓ Accepted answer

Your problem is your logic is backwards:

local plr = game.Players.LocalPlayer

function Down()
	if not plr.AFK.Value then --aka if plr.AFK.Value ~= true then
		plr.AFK.Value = true
		script.Parent.Text = "Back"
	else
    		script.Parent.Text = "Go afk"
		plr.AFK.Value = false
	end
end

script.Parent.MouseButton1Click:connect(Down)

What the code was doing before was seeing that AFK.Value is true, and then setting it to true again!

1 comment

0

thanks

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