Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Collision Filtering specific group rand or higher? [closed]

Asked by 7 years ago
Edited 7 years ago

This question already has an answer here:

Group rank door cancollide = false for certain rank and 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.

01local group = 3309505
02local rank = 254
03local plyr = game.Players.LocalPlayer
04local PhysicsService = game:GetService("PhysicsService")
05local wallGroup = "WallGroup"
06local Group = "Group"
07 
08PhysicsService:CreateCollisionGroup(wallGroup)
09PhysicsService:CreateCollisionGroup(Group)
10 
11local wall = game.Workspace["Rank Door"]
12local Groupplayer = plyr~=nil and plyr:IsInGroup(group)==true and plyr:GetRankInGroup(group)>=rank
13 
14PhysicsService:SetPartCollisionGroup(wall, wallGroup)
15PhysicsService:SetPartCollisionGroup(Groupplayer, Group)
16 
17PhysicsService: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.

01local group = 3309505 --My group id is here
02local rank = 254 -- Lowest qualifying rank number (For example everyone from rank 65 and up can go through the door)
03 
04script.Parent.Touched:connect(function(p)
05    while p.Parent.Name~="Workspace" do
06        p = p.Parent
07    end
08    local plyr = game.Players:FindFirstChild(p.Name)
09    if plyr~=nil and plyr:IsInGroup(group)==true and plyr:GetRankInGroup(group)>=rank then
10        script.Parent.CanCollide = false
11        script.Parent.Transparency = 1
12        wait(.5)
13        script.Parent.CanCollide = true
14        script.Parent.Transparency = 1
15    end
16end)

Marked as Duplicate by hiimgoodpack, DragonOfWar900, and PyccknnXakep

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

try this

--this is in regular script

01-- This script will let people over a certain rank through the door
02-- Put this script inside the door.
03 
04local groupID = 3309505 -- The group ID the player must be in
05local rank = 254 -- The rank the player will need to get through (out of 255)
06 
07 
08script.Parent.Touched:connect(function(hit)
09    if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then
10        if (game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank) then
11            script.Parent.LocalScript.Disabled = false -- change "LocalScript to the localscript"
12            wait(1)
13            script.Parent.LocalScript.Disabled = true -- change "LocalScript to the localscript"
14        end
15    end
16end)

--this is in localscript

1while wait() do
2    script.Parent.CanCollide = false
3end
0
i already had something like this. It lets others go through because it sets off a cancollide = false then true sweetlittlegirlohhl -22 — 7y
0
im not good but thats what i think Araknala 14 — 7y
0
i have the same problom but it doesnt bother me Araknala 14 — 7y
Ad