So I Recently Stumbled Upon A Error In My Game It Says:
****Cannot Create Collision Group One Already Exists
So I Was Wondering How Could I Check To See If it Already Exists To Prevent Errors?
Here Is My Code:
physicsService = game:GetService'PhysicsService' for i = 1,3 do if physicsService:GetCollisionGroupName("Group"..i) then print("Collision Groups Exist!") else physicsService:CreateCollisionGroup("Group"..i) end end physicsService:CollisionGroupSetCollidable("Group1", "Group2", false)
Please Help As I Have Not Seen This Error Before.
I found a devforum post related to your error, you can try this
local PhysicsService = game:GetService("PhysicsService") local function CreateCollisionGroup(collisionGroupName) local createdGroups = PhysicsService:GetCollisionGroups() local collisionGroupExists = {} do for _, createdGroup in pairs(createdGroups) do collisionGroupExists[createdGroup] = true end end if not collisionGroupExists[collisionGroupName] then PhysicsService:CreateCollisionGroup(collisionGroupName) end end CreateCollisionGroup("Group1") CreateCollisionGroup("Group2") PhysicsService:CollisionGroupSetCollidable("Group1", "Group2", false)
I don't have much experience with PhysicsService, so this may not work Post: https://devforum.roblox.com/t/script-erroring-that-a-collision-group-already-exists-when-it-doesnt/322318