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

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

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by
KoreanBBQ 301 Moderation Voter
9 years ago

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)

0
Sorry but I know the asker personally and he asked me to only give him the code KoreanBBQ 301 — 9y
Ad

Answer this question