In my game, I have a gun which throws out shells when it fires. What I want is the shells to not collide with players. I have this script:
local PhysicsService = game:GetService('PhysicsService') local ShellGroup = "ShellGroup" local PlayersGroup = "PlayersGroup" print(script.Parent.Name) PhysicsService:CreateCollisionGroup(ShellGroup) PhysicsService:CreateCollisionGroup(PlayersGroup) PhysicsService:CollisionGroupSetCollidable('ShellGroup','PlayersGroup',false) local shell = script.Parent local character = game.Players.LocalPlayer.Character --the player's character PhysicsService:SetPartCollisionGroup(shell,'ShellGroup') for i, v in pairs(character:GetChildren()) do if v:IsA('BasePart') then print(v.Name) PhysicsService:SetPartCollisionGroup(v,'PlayersGroup') end end
This is in a LocalScript
, I tried a Script
too, but it has the same result; the output is: "Could not create Collision Group." at line 6.
This script is disabled in the tool. When the main script generates the shells, it :Clone()
s it and sets itsDisabled
to false. Then it sets the script's Parent
to the shell. These shells are in the script which generates them, which is inside the tool, which is inside the player's character. I tried to put the shells into a different parent, but there's no difference.
Also, before I tried to make the script just turn the shell's CanCollide
property off when they are on the ground, but I need something better than that.
I have no idea whats wrong, some pls help?