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 6 years ago
Edited 6 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.

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)

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 6 years ago
Edited 6 years ago

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
0
i already had something like this. It lets others go through because it sets off a cancollide = false then true sweetlittlegirlohhl -22 — 6y
0
im not good but thats what i think Araknala 14 — 6y
0
i have the same problom but it doesnt bother me Araknala 14 — 6y
Ad