PhysicsService But For Characters?

I’m trying to make a door that only certain people can go through, similar to PhysicsService/Collision Filtering, however it seems that it only works for BaseParts.

Is there anything similar to those features that would work on Players and/or Characters?

Loop through all the parts in a player’s character.

2 Likes

Try making something like a whitelist system
Make a table that a players username would be added too when they are whitelisted. Thats all scripting without using physicsservice

Don’t do this since if two players go in at the same time they’ll both be allowed in.

1 Like

Would allocations have to be made for accessories as well? Or simply just the 15 parts that make up R15 Characters?

As far as I know, no allocations for accessories are needed since they have CanCollide off.

Thankfully, I already have that portion of the script. Unfortunately, the issue now is letting those whitelisted individuals actually pass through the door.

Hmm, okay, I’ll test this out! Hopefully I’m able to get it to work, thank you for the idea!

1 Like
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")

local playersgroup = "Players"
local doors = "Doors"

PhysicsService:CreateCollisionGroup(playersgroup)
PhysicsService:CreateCollisionGroup(doors)

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetChildren()) do
			PhysicsService:SetPartCollisionGroup(v, playersgroup)
		end
	end)
end)

PhysicsService:CollisionGroupSetCollidable(playersgroup, doors, false)

Make an if conditional for the .PlayerAdded to whatever you want like:

game:GetService("Players").PlayerAdded:Connect(function(plr)
if plr.Name = "Urname"

And set the doors collision group to doors, I assume you know how to do those stuff.

1 Like

Many thanks!!! Your script worked flawlessly. I included a simple conditional and some SetPartCollisionGroups() – [Not sure if that part was necessary but I thought I might as well include it]. Now the wall filters amongst qualified/non-qualified people perfectly. Weirdly, this “error” comes up in the output, but it just seems to be irrelevant.

Thanks again, your assistance really made my day!!!

Oh, must be getting a non basepart from the character, you can fix this by doing:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetChildren()) do 
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v, playersgroup)
			end
		end
	end)
end)

1 Like

Thank you so much!! I really appreciate you taking the time to help!

No problem, anytime. :slightly_smiling_face:

1 Like