I wanted to know if it was possible to make only a certain player nocollide with an object. For example, here's a scenario (the names are just for examples):
One player decided to join a server. Another one decided to join him. The first player will be named builderman and the second player will be called shedletsky. Builderman walks up to a door and he's able to access it, and enter it, however shedletsky cannot. Builderman cannot even possibly open the door for shedletsky because only builderman can go through it. This is due to builderman reaching a specific requirement and is nocollided with the door, but since shedletsky isn't, the door stays collidable with him.
Ending the scenario, here's what I got down so far. The "requirement" stated is being in a certain group. However, I find that while difficult, it is not impossible to keep the door open for another player (who is supposed to be restricted from entering). How would I be able to make it so that only a certain player meeting that one requirement is only nocollided with that one object, while the other one still cannot enter despite trying to hold it open (or keep it open).
script.Parent.Touched:connect(function(hit) if not hit.Parent:findFirstChild("Humanoid") then return end local plr = hit.Parent if plr:IsInGroup(GroupA) then script.Parent.CanCollide = false wait(0.3) -- My friend and I tested if it was possible to go through a door with only one of us having the requirement and it took a while, but wasn't impossible. script.Parent.CanCollide = true elseif plr:IsInGroup(GroupB) then script.Parent.CanCollide = false wait(0.3) script.Parent.CanCollide = true end end)
The door seems to work fine now, but yes, someone could get in, I've modified the script to detect if a player Is NOT in the groups, and if so, it will stop that player from entering.
-- normally, I'd add a debounce, but for keeping players out, it actually hurts more than it helps script.Parent.Touched:connect(function(hit) if not hit.Parent:findFirstChild("Humanoid") then return end local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr:IsInGroup(GroupA) then script.Parent.CanCollide = false wait(0.3) script.Parent.CanCollide = true elseif plr:IsInGroup(GroupB) then script.Parent.CanCollide = false wait(0.3) script.Parent.CanCollide = true else -- Added an else function, so if they're not in either group, the lines below fire hit.Anchored = true -- anchor the perpetrator, to stop him if he has really high walkspeed script.Parent.CanCollide = true -- door can collide wait(0) -- wait just long enough to keep the player from clipping through the door hit.Anchored = false -- unAnchor the perpetrator so he can still move -- if you're the perpetrator, the only thing you'll notice is a tiny bit of a jitter, and that you cannot into wall. end end)