What I am trying to achieve is a system, where players can go through each other.
The issue is, the script that I’ve used, that was located on the roblox wiki randomly stopped working. To be more clear, the script doesn’t work on the main game, but on another place it works. Code:
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
local playerCollisionGroupName = "Players"
PhysicsService:CreateCollisionGroup(playerCollisionGroupName)
PhysicsService:CollisionGroupSetCollidable(playerCollisionGroupName, playerCollisionGroupName, false)
local previousCollisionGroups = {}
local function setCollisionGroup(object)
if object:IsA("BasePart") then
previousCollisionGroups[object] = object.CollisionGroupId
PhysicsService:SetPartCollisionGroup(object, playerCollisionGroupName)
end
end
local function setCollisionGroupRecursive(object)
setCollisionGroup(object)
for _, child in ipairs(object:GetChildren()) do
setCollisionGroupRecursive(child)
end
end
local function resetCollisionGroup(object)
local previousCollisionGroupId = previousCollisionGroups[object]
if not previousCollisionGroupId then return end
local previousCollisionGroupName = PhysicsService:GetCollisionGroupName(previousCollisionGroupId)
if not previousCollisionGroupName then return end
PhysicsService:SetPartCollisionGroup(object, previousCollisionGroupName)
previousCollisionGroups[object] = nil
end
local function onCharacterAdded(character)
setCollisionGroupRecursive(character)
character.DescendantAdded:Connect(setCollisionGroup)
character.DescendantRemoving:Connect(resetCollisionGroup)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
lua
Keep in mind, there is no errors whatsoever, and I added a print, one at the start, and one at the end, and both prints came through, signifying that the whole script has been run. The script should be working, as it worked on another place, even after this issue occurred, and the script worked originally in the same place, that it stopped working on.
I have tried looking on Developer Forums for help, roblox developer hub, and friends, but no fix has been found to this day.