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)
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
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)
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)