local button = script.Parent
local model = game.ReplicatedStorage.tie
local backup = model:Clone()
local nAccess = script.Parent.Parent.Parent.NilAccess
local access = nil
if game.Players.LocalPlayer:GetRankInGroup(13987544) <= 255 then access = true
elseif game.Players.LocalPlayer:GetRankInGroup(13987544) == 0 then access = false
script.Parent.MouseButton1Click:Connect(function()
if access == true then
wait(2)
model = backup:Clone()
model.Parent = game.Workspace
model:MakeJoints()
elseif access == false then
nAccess.Visible = true
wait(2)
nAccess.Visible = false
end
end)
end
I have made a few edits but it still isn't working
Alright, my code may be a bit messy but I'm still fairly new to lua. I want this button to clone a model only if they are a certain rank in said group but display a GUI that says they don't have access if they aren't in said group. This doesn't display any errors and doesn't clone any model; but the no access GUI didn't pop up. How could I do that?

3 comments
Your function is inside the block created by your elseif on line 8. Which means it will only run if the player's Rank is equal to 0. Either move your funtion down or move the "if"'s inside the function.
It depends on if you want to check the player's rank only when the script first runs or every time they click the button. You should also consider adding a debounce as this button can be clicked multiple times.
BTW this can easily be bypassed with exploits.