My script is not working

Hey, developers so I have made a script that makes it so that you don’t collide with other people.I have tested it in Roblox studio and it seems to work I committed the script but when I go to the actual game on Roblox it doesn’t seem to work if any of you could help me please let me know :slight_smile:

thanks Toygrab

can we a script maybe?

(characters needed)

I’m not sure what you mean do you want me to put the script?

well. Nobody can help you unless you show us the script!

this is the script

There are no errors and it seems to work in testing in roblox studio but not in the actual game in roblox.

Please check the output for errors first, then come back to us with the results.
image

Also you could just :Connect(function() CharacterAdded after PlayerAdded.

no errors

(one at the top if from a different script i messed up then fixed)

There is a Roblox Article on this

Full Script:

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)

(If it still does not work then it’s a probably a Roblox problem. Try testing on a new game)

I suggest @Toygrab studies through the script and tries to understand it instead of calling it a day, if you need anything let us know.


dosen’t work

have you heard of the collision service plugin? you dont need to set it up in a script, just use the plugin instead

The red text actually is an error, can you show us what it says?

Edit: Didn’t read the other replies, my bad.