repeat wait() until game:IsLoaded()
local function onCharacterAdded(character)
print("g")
local player = script.Parent
local PhysicsService = game:GetService("PhysicsService")
for i,v in pairs(player:GetDescendants()) do
if v:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(v, "Players")
print("f")
end
end
end
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)
local function onDescendantAdded(descendant)
-- Set collision group for any part descendant
if descendant:IsA("BasePart") then
descendant.CollisionGroup = "Players"
end
end
local function onCharacterAdded(character)
-- Process existing and new descendants for physics setup
for _, descendant in character:GetDescendants() do
onDescendantAdded(descendant)
end
character.DescendantAdded:Connect(onDescendantAdded)
end
Players.PlayerAdded:Connect(function(player)
-- Detect when the player's character is added
player.CharacterAdded:Connect(onCharacterAdded)
end)