I am trying to make a group rank gate, that involves a button and a moving gate. The gate scripts works on its own but when I put it in the group rank script it breaks. This is how I have put both of them together for the group id gate. Script:
local groupID = 5090636 --Group ID
local rankNumber = 255 --Role Number
local higherRanksAllowed = true --Only works with rank numbers
function myFunction()
--Do stuff here
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
function clicked(player)
if player:IsInGroup(groupID) then
if rankNumber ~= nil then --Rank Number
if player:GetRankInGroup(groupID) == rankNumber then
myFunction()
elseif player:GetRankInGroup(groupID) > rankNumber and higherRanksAllowed then
myFunction()
end
discontinueScript = true
elseif roleName ~= nil and not discontinueScript then
if player:GetRoleInGroup(groupID) == roleName then
myFunction()
end
else
error("No valid rank number or role name set!")
end
end
end
script.Parent.ClickDetector.MouseClick:connect(clicked)
