im trying to get the children of the player’s character without it coming out as an error, like in the output: 16:28:06.766 - Workspace.Script:17: attempt to index nil with ‘GetDescendants’
ive tried and failed please help me.
script:
local Array = {"ok","ys","epicgamer","ok"
}
local Players = game:GetService('Players')
local GetPlayers = Players:GetPlayers()
game.Players.PlayerAdded:Connect(function(plr)
table.insert(Array,plr.Name)
end)
local function FindPlayerInArray()
for _, Target in ipairs(Players:GetPlayers()) do
for _, Search in ipairs(Array) do
if Target.Name:lower() == Search:lower() then
print(Target.Name.." is in array")
game.ReplicatedStorage.RemoteEvent:FireClient(Target)
local part = Instance.new("Part")
part.Parent = workspace
local v = Target.Character:GetDescendants()
v:Destroy()
return true
end
end
end
print("not in array")
end
while wait(1) do
FindPlayerInArray()
end