Gate Script Group Rank ID

Using this script that opens a gate when a button is clicked, how could I amplify it so it only works if you are a certain rank in a certain group.

local trigger = script.Parent
local gate = script.Parent.Parent.Gate

moving = false
open = false

function onClick()

	if open == false and moving == false then

		moving = true
		trigger.BrickColor = BrickColor.new("Bright yellow")

		for i = 1, (gate.Size.Y * 10 + 1) do
			wait()
			gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0)
		end
	
		moving = false
		open = true
		trigger.BrickColor = BrickColor.new("Bright red")

	elseif open == true and moving == false then

		moving = true
		trigger.BrickColor = BrickColor.new("Bright yellow")
		
		for i = 1, (gate.Size.Y * 10 + 1) do
			wait()
			gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0)
		end
	
		moving = false
		open = false
		trigger.BrickColor = BrickColor.new("Bright green")

	end

end

script.Parent.ClickDetector.MouseClick:connect(onClick)

Thanks!

1 Like

Also, I’d recommend using tweens to move the door.

1 Like
local groupId = --use your group id
local requiredRank = --enter the required rank(like 255, for example)

if player:GetRankInGroup(groupId) >=requiredRank then --i edited this
     --open the door
end

This was just a little example to help you.

1 Like

It is player:GetRankInGroup(groupId) >= requiredRank

local groupId = 4097817 --use your group id
local requiredRank = 8 --enter the required rank(like 255, for example)

if player:GetRankInGroup >=requiredRank then
local trigger = script.Parent
local gate = script.Parent.Parent.Gate

moving = false
open = false

function onClick()

	if open == false and moving == false then

		moving = true
		trigger.BrickColor = BrickColor.new("Bright yellow")

		for i = 1, (gate.Size.Y * 10 + 1) do
			wait()
			gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0)
		end
	
		moving = false
		open = true
		trigger.BrickColor = BrickColor.new("Bright red")

	elseif open == true and moving == false then

		moving = true
		trigger.BrickColor = BrickColor.new("Bright yellow")
		
		for i = 1, (gate.Size.Y * 10 + 1) do
			wait()
			gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0)
		end
	
		moving = false
		open = false
		trigger.BrickColor = BrickColor.new("Bright green")

	end

end

script.Parent.ClickDetector.MouseClick:connect(onClick)

**I tried this however it did not work. :frowning: **

local groupId = 4097817 --use your group id
local requiredRank = 8 --enter the required rank(like 255, for example)

local trigger = script.Parent
local gate = script.Parent.Parent.Gate

moving = false
open = false

function onClick(player)
     if player:GetRankInGroup(groupId) >=requiredRank then
    if open == false and moving == false then

	moving = true
	trigger.BrickColor = BrickColor.new("Bright yellow")

	for i = 1, (gate.Size.Y * 10 + 1) do
		wait()
		gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0)
	end

	moving = false
	open = true
	trigger.BrickColor = BrickColor.new("Bright red")

elseif open == true and moving == false then

	moving = true
	trigger.BrickColor = BrickColor.new("Bright yellow")
	
	for i = 1, (gate.Size.Y * 10 + 1) do
		wait()
		gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0)
	end

	moving = false
	open = false
	trigger.BrickColor = BrickColor.new("Bright green")

end

end

script.Parent.ClickDetector.MouseClick:connect(onClick)

I didn’t test this script, but go check to see if it works. (Also, I messed up in my previous example, and just fixed it in this script)

I honestly think this wouldn’t work at all, basically, connect(C in lower case) is deprecated, you should use Connect(C in upper case) instead.

It would still work.

30 characters

Some things would probably break.

It does not work.. ¯_(ツ)_/¯

30 charecters :confused:

[spoiler] 30 charss [/spoiler]

1 Like