#AFK System problem (welp)
8 messages · Page 1 of 1 (latest)
-
Remove the pairs, it's no longer needed. You can simply leave it out like so:
for i,v in someTable do end -
address the character correctly so you won't have any errors if a player leaves.
if not character then return end -
Use
:IsA("BasePart"), it will include all the kinds of parts. -
Inside Accessories use
:FindFirstChildWhichIsA("BasePart") -
Remove the last for loops of sand
@stray stirrup
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
).
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)`
