Frame is not becoming visible for some reason

  1. What do you want to achieve? Keep it simple and clear!
    I want the gui to show up for the individual player when the ClickDetector is clicked
  2. What is the issue? Include screenshots / videos if possible!
    Whenever I click the button, the script doesn’t run
local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player.PlayerGui
local repStorage = game:GetService("ReplicatedStorage")
button.MouseClick:Connect(function()
	print("Button Pressed")
	local rank = player:GetRankInGroup(14289900)
	if rank >= 3 then
playerGui.ChalkBoardGui.Frame.Visible = true
		print("Player is Staff Sergeant+")
	elseif rank <3 then
		print("Player is not Staff Sergeant.")
	end
	
end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve reviewed the code, and i’m pretty positive everything is correct

This is in a local script.

2 Likes

Have you tried using Button.MouseButton1Click?

I could try, but it’s in a click detector.

--//Services
local Players = game:GetService("Players")

--//Variables
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local Button = script.Parent

--//Functions
Button.MouseButton1Click:Connect(function()
	local rank = LocalPlayer:GetRankInGroup(14289900)
	
	if rank >= 3 then
		PlayerGui.ChalkBoardGui.Frame.Visible = true
		
		print("Player is Staff Sergeant+")
	elseif rank <3 then
		print("Player is not Staff Sergeant.")
	end
end)

Click detectors don’t work on UI buttons.

In that case it won’t work. My bad, I though it was a textButton.

Do you mean I can’t use a click detector to open a UI? Cause that’s what I am trying to do.

No, I’m saying that you can’t connect a function to a click detector that’s inside of a UI button.

Replied to wrong person, sorry.

The LocalScript probably isn’t running at all if it’s a descendant of workspace. Move the LocalScript into one of these listed on the wiki and have it reference the click detector in workspace.

The click detector is in a part. The function of the click detector is to open a UI.
So if you click the part (ClickDetector) then it will open a UI.

Try this instead: (put it in a normal script)

--//Variables
local Button = script.Parent

--//Functions
Button.ClickDetector.MouseClick:Connect(function(Player)
	local rank = Player:GetRankInGroup(14289900)

	if rank >= 3 then
		Player.PlayerGui.ChalkBoardGui.Frame.Visible = true

		print("Player is Staff Sergeant+")
	elseif rank <3 then
		print("Player is not Staff Sergeant.")
	end
end)
2 Likes

you can always check here for more info.

Local scripts only work when they’re descended from the player, not when they’re in workspace. You need to use a script instead.