Collision group problem

so i am using this script to set the character’s collision group:

game.Players.PlayerAdded:Connect(function(plr)

	plr.CharacterAdded:Connect(function(char)
		for _,part in pairs(char:GetDescendants()) do
			if part:IsA("BasePart") then
				part.CollisionGroup = "Player"
			end
		end
	end)
end)


when i stand on noplayer, i can still stand on it. but when i set the cancolide on the legs it works, but it goes back to false after, any idea what i can do here?

Can you confirm that the part you are standing on does have the NoPlayer collision group? I have tested your code and collision groups and they both work fine.