Ad
Log in to vote
0

My collision groups don't work on players?

Asked by 4 days ago

Hi, I'm making a script that you can walk through other players. I can still walk through other players. What am I doing wrong?

Script:

local PhysicsService = game:GetService("PhysicsService")

local CollisionGroupName = "Players"

PhysicsService:CreateCollisionGroup(CollisionGroupName)

PhysicsService:CollisionGroupSetCollidable(CollisionGroupName, CollisionGroupName, false)

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)

    Player.CharacterAdded:Connect(function(Character)

        for _,Child in pairs(Character:GetChildren()) do

            if Child:IsA("BasePart") then

                PhysicsService:SetPartCollisionGroup(Child, CollisionGroupName)
            end
        end
    end)
end)

Script Location: ServerScriptService, a server script.

1
your question is not clear but if you want players to not collide then thats what your code does for me, if its not doing that for you then it might be because the children of the character hasnt had time to load in enzotinman1 22 — 4d
0
Not clear, I'm using collision groups for all players so they can walk through each other and not push each other. The last thing you said fixed it, thanks. Bankrovers 104 — 4d

1 answer

Log in to vote
0
Answered by 4 days ago

I fixed the issue with waiting for the character to fully load. The parts of the character were not yet loaded into my script.

Ad

Answer this question