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
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)
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
--//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)
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.
--//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)