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

Check if 'AFK' is a member of player help?

So I tried making this to check if there is a boolean called "AFK" in the player so they don't get the bool value in their player twice. but, this doesn't work.

game.Players.PlayerAdded:connect(function(player)
	FindBool = player:FindFirstChild("AFK")
	player.CharacterAdded:connect(function(character)
		if FindBool == false then
		Instance.new("BoolValue",player)
		player.Value.Name = "AFK"
		character.Humanoid.WalkSpeed = 0
		else
		end
	end)
end)

1 answer

✓ Accepted answer

Put this in a ServerScript

game.Players.PlayerAdded:connect(function(player)
    local already = false
    player.CharacterAdded:connect(function(character)
       for i,v in pairs(player:GetChildren()) do
		if v.Name=="AFK" then
		already=true
		end
	end
	if not already then
	local afk=Instance.new("BoolValue",player)
	afk.Name="AFK"
	end
    end)
end)

2 comments

0

Sorry but I know the asker personally and he asked me to only give him the code

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