Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Collision Filtering specific group rand or higher?

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)

1 answer

try this

--this is in regular script

-- This script will let people over a certain rank through the door
-- Put this script inside the door.

local groupID = 3309505 -- The group ID the player must be in
local rank = 254 -- The rank the player will need to get through (out of 255)


script.Parent.Touched:connect(function(hit)
	if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then
		if (game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank) then
			script.Parent.LocalScript.Disabled = false -- change "LocalScript to the localscript"
			wait(1)
			script.Parent.LocalScript.Disabled = true -- change "LocalScript to the localscript"
		end
	end
end)

--this is in localscript

while wait() do
	script.Parent.CanCollide = false
end

3 comments

0

i already had something like this. It lets others go through because it sets off a cancollide = false then true

0

im not good but thats what i think

0

i have the same problom but it doesnt bother me

This discussion is preserved as it was. New answers, comments, and votes are closed.