Hi devs,
im making it so an npc occasionally disappears. inorder to achieve this, i set all the parts of the npcs cancollide off, however, when i set the humanoidrootparts cancollide to off and then anchor it, it puts cancollide on automatically in game. This gives the players a chance to hit it. Does anybody know any solutions
Humanoid root part’s cancolide property is set to true in loop by studio automaticaly, because it is root part specified in humanoids object, the only thing that might work is teleporting it off the map, or adding if statement while executing hit code
when i try set all the parts in the player to the collision group with a loop that goes through all the players, it tries to set the humanoid to the group which breaks it
local PhysicsService = game:GetService(“PhysicsService”)
local root = “root”
local plr = “plr”
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
– Register two collision groups
PhysicsService:RegisterCollisionGroup(root)
PhysicsService:RegisterCollisionGroup(plr)
workspace.Ghost.Noobnoobie87.HumanoidRootPart.CollisionGroup = root
local children = player.Character:GetChildren()
for i = 1, #children do
children[i].CollisionGroup = plr
end
PhysicsService:CollisionGroupSetCollidable(root, plr, false)
end)
end)
That’s because you are performing any checks to make sure that the Instance is a BasePart and the result is the code trying to apply the property on an Instance that does not inherit it.
All BaseParts Inherit the CollisionGroup Property, so It would be safe to validate that it is a BasePart using :IsA()