So I’ve been trying to make a collision group so no players can collide with a npc but i honestly don’t get it. I’ve read topics about collision groups on the devforum but i don’t get how i would apply it to what i am doing.
3 Likes
I’m not much of a scripter, and I’m on mobile, but I’m just making a educated guess, can’t you make the npc CanCollide = off?
You should check out PhysicsService on the wiki as it will be the best method to achieve what you’re looking for, if you have any questions feel free to ask.
1 Like
local physics = game:GetService("PhysicsService")
physics:CreateCollisionGroup("playersGroup")
physics:CreateCollisionGroup("npcsGroup")
--Sets up the collision groups ^
physics:CollisionGroupSetCollidable("playersGroup", "npcsGroup", false)
--Making the groups cancollide false
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(char)
for _, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
physics:SetPartCollisionGroup(v, "playersGroup")
end
end
end)
end)
--waits for char to load in then sets its parts to the collision group
for _, v in pairs(workspace:WaitForChild("npcFolder"):GetChildren()) do
for _, part in pairs(v:GetChildren()) do
if part:IsA("BasePart") then
physics:SetPartCollisionGroup(part, "npcsGroup")
end
end
end
--looks inside a folder in workspace and sets all the npc's parts within it to the collision group, you may want to change this part to fit your set up but this should give you the general idea
12 Likes