So I have a Control Room with multiple alarms and I wondering how to rank lock the buttons so only Executives can use the alarms.
OnButton Script
function onClicked()
workspace.Alarms.CodeBlack:Play()
for i, Part in pairs(workspace.Lights:GetChildren()) do
if Part.Name == "Part" then
Part.Color = Color3.fromRGB(0, 0, 0)
Part.SurfaceLight.Color = Color3.fromRGB(0, 0, 0)
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(Player)
if Player:GetRankInGroup(groupId) < 250 then return end
-- script will only get here if the player's rank is greater than or equal to 250
function onClicked(Player)
if Player:GetRankInGroup(groupId) < 250 then return
workspace.Alarms.CodeBlack:Play()
for i, Part in pairs(workspace.Lights:GetChildren()) do
if Part.Name == "Part" then
Part.Color = Color3.fromRGB(0, 0, 0)
Part.SurfaceLight.Color = Color3.fromRGB(0, 0, 0)
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(Player)
if Player:GetRankInGroup(groupId) < 250 then return end -- if rank < 250 then stop function and close out the if statement
workspace.Alarms.CodeBlack:Play()
for i, Part in pairs(workspace.Lights:GetChildren()) do
if Part.Name == "Part" then
Part.Color = Color3.fromRGB(0, 0, 0)
Part.SurfaceLight.Color = Color3.fromRGB(0, 0, 0)
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(Player)
if Player:GetRankInGroup(groupId) < 250 then return end
workspace.Alarms.CodeBlack:Play()
for i, Part in pairs(workspace.Lights:GetChildren()) do
if Part.Name == "Part" then
Part.Color = Color3.fromRGB(0, 0, 0)
Part.SurfaceLight.Color = Color3.fromRGB(0, 0, 0)
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I tested it and it worked, thanks bro [Also if I wanted to add another group would I do something like…
if Player:GetRankInGroup(groupId) < 250 or if Player:GetRankInGroup(gruopID) < 233 then return end
local Groups = {
[12345678] = 250,
[90852323] = 233
}
function onClicked(Player)
local Authorized = false
for ID, MinimumRank in pairs(Groups) do
if Player:GetRankInGroup(ID) >= MinimumRank then
Authorized = true
break
end
end
if Authorized then
workspace.Alarms.CodeBlack:Play()
for i, Part in pairs(workspace.Lights:GetChildren()) do
if Part.Name == "Part" then
Part.Color = Color3.fromRGB(0, 0, 0)
Part.SurfaceLight.Color = Color3.fromRGB(0, 0, 0)
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)