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?
local button = script.Parent local model = game.ReplicatedStorage:WaitForChild("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 end script.Parent.MouseButton1Click:Connect(function() if access then --In Lua you can just pass a bool and if it's true it will complete the `if` wait(2) model = model:Clone() model.Parent = game.Workspace model:MakeJoints() elseif access == false then nAccess.Visible = true wait(2) nAccess.Visible = false end end)
I mainly just changed where the event listener was. In the first script, you created the event listener only if they didn't have access to the group. This means if they did have access to the group the event listener wouldn't be there and they wouldn't be able to press the button. I'm assuming NilAccess
is a Frame
so the .Visible
property would stay the same but if NilAccess
is a ScreenGui
object (the little white box in a blue box) then you should change the .Visible
in the elseif to Enabled
. If this did fix the problem please mark it as the answer. I hope this did help! Good Luck