I am having trouble with collision filtering. I made a script that would let only players in a specific rank or higher in the group go through the door. This is my script and it doesn't work. I am not very good at scripting.
local group = 3309505
local rank = 254
local plyr = game.Players.LocalPlayer
local PhysicsService = game:GetService("PhysicsService")
local wallGroup = "WallGroup"
local Group = "Group"
PhysicsService:CreateCollisionGroup(wallGroup)
PhysicsService:CreateCollisionGroup(Group)
local wall = game.Workspace["Rank Door"]
local Groupplayer = plyr~=nil and plyr:IsInGroup(group)==true and plyr:GetRankInGroup(group)>=rank
PhysicsService:SetPartCollisionGroup(wall, wallGroup)
PhysicsService:SetPartCollisionGroup(Groupplayer, Group)
PhysicsService:CollisionGroupSetCollidable(wallGroup, Group, false)
here is my old script that didnt use collision filtering and it let others (who werent allowed in), in with the player who is allowed to go in. Soo it didnt work out so well. I dont want a script like this please. I need to us collision filtering on this.
local group = 3309505 --My group id is here
local rank = 254 -- Lowest qualifying rank number (For example everyone from rank 65 and up can go through the door)
script.Parent.Touched:connect(function(p)
while p.Parent.Name~="Workspace" do
p = p.Parent
end
local plyr = game.Players:FindFirstChild(p.Name)
if plyr~=nil and plyr:IsInGroup(group)==true and plyr:GetRankInGroup(group)>=rank then
script.Parent.CanCollide = false
script.Parent.Transparency = 1
wait(.5)
script.Parent.CanCollide = true
script.Parent.Transparency = 1
end
end)

3 comments
i already had something like this. It lets others go through because it sets off a cancollide = false then true
im not good but thats what i think
i have the same problom but it doesnt bother me