Hello, I am making a simple AFK checker for my game but I have come across this issue while making it work. Error: attempt to index nil with ‘Value’. This is a server script in ServerScriptService. It occurs on char:FindFirstChild("afkTag).Value. Can someone help? Thanks. Here is my current code:
for i,player in pairs(plrs) do
if player then
local char = player.Character
if char then
if char:FindFirstChild("afkTag").Value == false then
char:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawns[1].CFrame + Vector3.new(0,2,0)
table.remove(AvailableSpawns,1)
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = char
end
end
else
if not player then
table.remove(plrs,i)
end
end
end
And here is where it gets created: (local script inside starterplayerscripts)
local plr = game.Players.LocalPlayer
local afkTag = Instance.new("BoolValue")
afkTag.Value = false
afkTag.Parent = plr.Character
afkTag.Name = "afkTag"
EDIT: I have just realized that afkTag is not creating. Disregard the first script, does anyone know why the local script doesn’t instance.new()?