Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Could not create Collision Group. Why?

Asked by 7 years ago

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?

1
First of all it must be inside a Script, it's the server to call those function, not the client. Also try to put it inside the ServerScriptService, but it's strange it should work. Mmhh, do what I say and if it doesn't work I'll figure it out. alessandro112 161 — 7y
0
I will try your suggestion when I have some more time. Thank you :D RiskoZoSlovenska 378 — 7y

Answer this question