I’m scripting a chat command to toggle player collisions, but I don’t know how to script the player collisions off, which means the player can collide with normal parts, but not other players. How would I do something like this? I already have the script for detecting the chat word set up, I just need some help with this part. Thanks!
This code should work, it’s taken apart from the Team Door article on the wiki.
local PhysicsService = game:GetService("PhysicsService") local playerGroup = "PlayerCharacter" PhysicsService:CreateCollisionGroup(playerGroup) local function setCollisionGroup(character, groupName) for _, child in ipairs(character:GetChildren()) do if child:IsA("BasePart") then PhysicsService:SetPartCollisionGroup(child, groupName) end end character.DescendantAdded:Connect(function(descendant) if descendant:IsA("BasePart") then PhysicsService:SetPartCollisionGroup(descendant, groupName) end end) end local Players = game:GetService("Players") local function onPlayerAdded(player) local function onCharacterAdded(character) setCollisionGroup(character, playerGroup) end player.CharacterAdded:Connect(onCharacterAdded) end Players.PlayerAdded:Connect(onPlayerAdded) PhysicsService:CollisionGroupSetCollidable(playerGroup, playerGroup, false)
Sorry, I think I misspoke. I am looking for a way to make players not be able to collide with each other, but still be able to collide with other parts normally. I’ll edit the post, but thanks for that script, it will help with other projects.
That’s what this script should do… That’s exactly what that script should do.
I have the same mechanic in my game…
Oh, sorry. I was looking through the script before I added it in. I always look through them, just to make sure it’s what I’m trying to find before I add it in. I saw BasePart, and thought it meant as in base plate. My fault. I’ll try it out.
BasePart is the main class for Part. It’s used for Part, Union, Wedge, etc.