#AFK System problem (welp)

8 messages · Page 1 of 1 (latest)

stray stirrup
past ingot
#
  1. Remove the pairs, it's no longer needed. You can simply leave it out like so:
    for i,v in someTable do end

  2. address the character correctly so you won't have any errors if a player leaves.
    if not character then return end

  3. Use :IsA("BasePart"), it will include all the kinds of parts.

  4. Inside Accessories use
    :FindFirstChildWhichIsA("BasePart")

  5. Remove the last for loops of sand

#

@stray stirrup

stray stirrup
# past ingot <@941480238582489088>

Hi, thanks for the help, I tried it but the problem persists, the face, the shirt and the gloves are not affected by the script for some reason. Maybe I'm dumb (extremely probable) and I implemented your changes incorrectly (I'm new in this of the scripts, sorry j_walterwhite ).

#

I'll send the script with the changes.
.
.
.

#

`local AFKstatus = {}

local Event = game:GetService("ReplicatedStorage"):FindFirstChild("AFK")

if not Event then
Event = Instance.new("RemoteEvent")
Event.Parent = game:GetService("ReplicatedStorage")
Event.Name = "AFK"
end

local updateAFK = function(player, enable)
local character = player.Character
if not character then return end

if enable then
    for _, v in character:GetChildren() do
        if v:IsA("BasePart") then
            v.Material = "ForceField"
        end
    end
    for _, v in character:GetChildren() do
        if v:IsA("Accessory") then
            local Part = v:FindFirstChildWhichIsA("BasePart")
            if Part then
                Part.Material = "ForceField"
            end
        end
    end
else
    for _, v in character:GetChildren() do
        if v:IsA("BasePart") then
            v.Material = "Sand"
        end
    end
    for _, v in character:GetChildren() do
        if v:IsA("Accessory") then
            local Part = v:FindFirstChildWhichIsA("BasePart")
            if Part then
                Part.Material = "Sand"
            end
        end
    end
end

end

Event.OnServerEvent:Connect(function(player, enable)
AFKstatus[player] = enable
updateAFK(player, enable)
end)`

past ingot
#

You'll have to use the .Transparency property on the rest, I think you can understand how this works.

#

You can also use GetDescendants but that's bad practice.