Hi, when a player enters the game, apparently I can still collide with him. This is how the console looks like:
As you can see, every child of the player’s character is added to the collision group, but I can still collide with the player.
Code:
-- SERVICES
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
-- VARIABLES
local VipDoor: Part = workspace:WaitForChild("VipDoor") :: Part
local GroupId: number = 13519293
local NoCollisionsGroupKey: string = "NoCollisions"
local NoCollisionsGroup: number = PhysicsService:CreateCollisionGroup(NoCollisionsGroupKey)
-- FUNCTIONS
function ApplyNoCollisionsGroup(character: Model): ()
for characterChildIndex: number, characterChild: Instance in ipairs(character:GetDescendants()) do
if characterChild:IsA("BasePart") then
warn("[NO COLLISIONS] " .. Players:GetPlayerFromCharacter(character).Name .. " | " .. characterChild.Name)
PhysicsService:SetPartCollisionGroup(characterChild, NoCollisionsGroupKey)
end
end
end
-- SOURCE
PhysicsService:CollisionGroupSetCollidable(NoCollisionsGroupKey, NoCollisionsGroupKey, false)
Players.PlayerAdded:Connect(function(player: Player)
if player.Character then
ApplyNoCollisionsGroup(player.Character)
if player:IsInGroup(GroupId) then
PhysicsService:SetPartCollisionGroup(VipDoor, NoCollisionsGroupKey)
warn("[NO COLLISIONS - VIP DOOR] " .. player.Name)
end
else
player.CharacterAdded:Connect(function(character: Model)
ApplyNoCollisionsGroup(character)
if player:IsInGroup(GroupId) then
PhysicsService:SetPartCollisionGroup(VipDoor, NoCollisionsGroupKey)
warn("[NO COLLISIONS - VIP DOOR] " .. player.Name)
end
end)
end
end)
Bump! (x1)