Attempt to index nil error but i am using GetDescendants()

So i want every player to have their own unique collision group
Everyone will a part that can collide with the default collision group and the player. I already set the collisions and also registered the player’s collision group when they join in a different script but when i want to change their descendants’ collision group i get an error saying

Workspace.ertubasikax.LocalScript:3: attempt to index nil with ‘IsA’

This script is in starter character scripts btw

local function onDescendantAdded(descendant)
	if descendant:IsA("BasePart") then
		descendant.CollisionGroup = game.Players.LocalPlayer.Name
	end
end

for _,v in ipairs(script.Parent:GetDescendants()) do
	onDescendantAdded(v)
end
script.Parent.DescendantAdded:Connect(onDescendantAdded())

replace that with

script.Parent.DescendantAdded:Connect(onDescendantAdded)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.