I have a door which I made using HingeConstraints. So you just walk into the door and it swings open. I want to make it so that behavior where it opens will only happen if the player that walks into it is a part of a certain team, lets call it “team a”. So “team a” should be able to interact with this door, but no other team, including people without a team. How would I go about doing this?
I think what you could do is you could get a local script and type smth like this:
local door = workspace.DoorPart -- Your Door
local plr : Player = game.Players.LocalPlayer -- Player
if plr.Team == "YourTeam" then
door.Anchored = false
else
door.Anchored = true
end
What this should do is that if the player is on the team, the door will be unanchored, allowing it to move freely. However, if they are not, the door part will be anchored, so it will be unable to be affected by the hinge. MAKE SURE IT IS LOCAL SCRIPT
Green = Unanchored Door Part
Red = Anchored Door Part
Lemme know if this helps!
The previous reply is probably the solution you are looking for.
However, I came here to say that if you want server authority instead of trusting the client to set the door to anchored, you could make the door out of 2 parts: a part that does the swinging, but is only collidable to the team. (probably good idea to have a team only “wall” there regardless how the door is implemented not only to prevent exploiters but also prevent people from tailgating someone into the restricted area).
In addition to the team only wall which collides with the non authorized team, the door should only collide with the authorized team (so the other team can’t push it). Have another piece which collides and aligns position to the pushed part. (so only one team can push it)
The logic here is that if you phase through the door, you can’t push it. However, you can’t walk through it since the door need to swing to move the part that you will collide with, but aligns position to door.
Doing this on the server will not prevent exploiters from bypassing it, unless op is using a server authoritative character controller (like chickynoid, or roblox’s upcoming solution?), then the exploiter can just use a tp or noclip exploit to go through the door (since the player’s character is client sided, for user experience reasons)