removed for reasons (lol limitttttttttttt)
Maybe even the parts are not created when the player model is created, you can use the CharacterAdded
function instantly and then connect it in case there is already a character, also use DescendantAdded
for new parts
--// Services
local __Physics_Service = game:GetService("PhysicsService")
--// Setting Values
__Physics_Service:CreateCollisionGroup("PlayersGroup")
__Physics_Service:CreateCollisionGroup("NpcsGroup")
__Physics_Service:CollisionGroupSetCollidable("PlayersGroup", "NpcsGroup", false)
--// Pathways
local _npc_Obj = game:GetService("ServerStorage").NPC_Storage
--// Setting Collisions
for _,NPC in pairs(_npc_Obj:GetChildren()) do
if NPC:IsA("Model") then
for _,v in pairs(NPC:GetDescendants()) do
if v:IsA("BasePart") then
__Physics_Service:SetPartCollisionGroup(v,"NpcsGroup")
end
end
end
end
--// Events
game:GetService("Players").PlayerAdded:Connect(function(local_player)
local function CharacterAdded(char)
if not char then return end
local function DescendantAdded(Part)
if not Part:IsA("BasePart") then return end
__Physics_Service:SetPartCollisionGroup(Part, "PlayersGroup")
end
char.DescendantAdded:Connect(DescendantAdded)
for _, Part in pairs(char:GetChildren()) do DescendantAdded(Part) end
end
CharacterAdded(local_player.Character)
local_player.CharacterAdded:Connect(CharacterAdded)
end)
removed for reasons (lol limitttttttttttt)
I presume that ‘collisions that aren’t working’ means that they are colliding with the players or something? I’m a bit stupid but hey I tried…
You should try a print(v)
in
this little if statement here to make sure its actually adding them to the CollisionGroup.
Also you can open the collisions menu or whatever it is called in the top menu bar where it says ‘Model’ and somewhere to the right there should be two spheres colliding as an icon called ‘Collision Groups’ that you can click. If you select some base parts in the NPCs or your Character their group will be highlighted in this menu, if it doesn’t say what it should or there are no group names there then I guess this has something to do with your issue. Your code looks absolutely fine to me, I’m probably missing something here but didn’t want to leave you hanging or completely lost