Well, technically speaking, scripts don't run at the same time. They run consecutively, and the order is determined by the thread scheduler. But aside from that, here's one option:
02 | Physics = game:GetService( "Physics" ) |
05 | local function IsCollisionGroupExisting(Name) |
06 | local IsSuccess = pcall ( function () |
07 | return Services.Physics:GetCollisionGroupId(Name) |
15 | if not IsCollisionGroupExisting(Name) then |
16 | Services.Physics:CreateCollisionGroup(Name) |
Of course, a much better approach would be to use one Script
and one LocalScript
for your entire game, and have all of your code rest in modules, so you don't get potential threading bugs like this one.