I want this script to make it so that the player is assigned a collision group that can pass through the door. The collision group does not work when it is assigned to the HumanoidRootPart, which I believed adding would assign the whole character to the group. I’m not sure how I should assign the whole character or if I am using the collision groups correctly.
local door = script.Parent
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
local secmember = "Secmember"
door.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player:IsInGroup(901313) then
local member = player.Character:FindFirstChild("HumanoidRootPart")
member.CollisionGroup = secmember
end
end
end)
As a note for the solution, make sure you do the group check during the playerAdded function.
Add a PlayerAdded event, and then check if the player is in the group, if they are, then a for i,v loop on their character and add any baseparts to the collisiongroup.
If you’re trying to make a group door, I’d recommend just checking if they’re in the group and just set the door’s collision to false (in a local script).