I have got a script inside my folder so when a NPC spawns they don’t collide with the player, this was working as expected in my test game, as soon as I copy it over it breaks, are there any reasons this doesn’t work in a certain game?
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(game.ReplicatedStorage.NPC_Possible: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'sa