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

How Can I Make this Group only Door to be able only Certain Ranks can Enter?

Hello, I want this Group only door to have an Rank only script... How can i do this?


GroupId = 00000 --Change this to your group's ID

function checkOkToLetIn(name) 
	if game.Players[name]:IsInGroup(GroupId) == true then return true end 
	return false 
end 

local Door = script.Parent

function onTouched(hit) 
	print("Door Hit") 
	local human = hit.Parent:findFirstChild("Humanoid") 
	if (human ~= nil ) then 
		-- A player did touch this door 
		print("Human touched door") 
		-- Let's see if he is in the group. 
		if (checkOkToLetIn(human.Parent.Name)) then 
			print("Human passed test") 
			Door.Transparency = 0.5 --how transparent the door gets. Changable
			Door.CanCollide = false --you can walk through the door.
			wait(4) -- this is how long the door is open. Changable
			Door.CanCollide = true -- non-walkable 
			Door.Transparency = 0 -- Looks closed to me!
			else humanoid.Health = 0 --This makes sure that if the dude is not in the group, he will be dead. Otherwise he could get in.
		end 
	end 
end 

script.Parent.Touched:connect(onTouched)

1 comment

0

if PLAYER:GetRankInGroup(ID) >= NUMBER then --This gets the Rank from the Group that which the player is in, edit it however you want.

1 answer

GroupId = 00000 --Change this to your group's ID

function checkOkToLetIn(name) 
    if game.Players[name]:IsInGroup(GroupId) == true and game.Players[name]:GetRankInGroup(GroupId) >= 2 then return true end -- the number 2 represents the Rank number. It ranges from 1-255
    return false 
end 

local Door = script.Parent

function onTouched(hit) 
    print("Door Hit") 
    local human = hit.Parent:findFirstChild("Humanoid") 
    if (human ~= nil ) then 
        -- A player did touch this door 
        print("Human touched door") 
        -- Let's see if he is in the group. 
        if (checkOkToLetIn(human.Parent.Name)) then 
            print("Human passed test") 
            Door.Transparency = 0.5 --how transparent the door gets. Changable
            Door.CanCollide = false --you can walk through the door.
            wait(4) -- this is how long the door is open. Changable
            Door.CanCollide = true -- non-walkable 
            Door.Transparency = 0 -- Looks closed to me!
            else humanoid.Health = 0 --This makes sure that if the dude is not in the group, he will be dead. Otherwise he could get in.
        end 
    end 
end 

script.Parent.Touched:connect(onTouched)


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