I'm trying to create a raiding system for war clans which includes a GUI with a few buttons which control the raid (i.e. making the raid official, voiding the raid). However, I need this GUI to only appear and be usable by HRs of a certain rank. This is my first time scripting something, so, as such, my lack of experience limits me from accomplishing my goal. The GUI itself is all done and scripted, but my only problem is having it only show up for certain players.
game.Players.PlayerAdded:connect(function(Player)
if Player:GetRankInGroup(2565156) == 255 then
script.Parent.ControlButton.Visible = true
script.Parent.ControlButton.Selectable = true
script.Parent.ControlButton.Active = true
else
script.Parent.ControlButton.Visible = false
script.Parent.ControlButton.Selectable = false
script.Parent.ControlButton.Active = false
end
end)
This is the script I created hoping it would work. I failed to realize that this would either make the GUI visible or invisible if an HR or non-group member or non-HR joined, respectively. I thought perhaps making the script a LocalScript would work since the GUI is in StarterGUI, but it didn't. I can't think of anything that would make the script only appear for certain players.

4 comments
If you need more help, teamcreate with me maybe
If I wanted to use the concept in the first example, how would I do that? Sorry, I'm really new to scripting and have little to no experience. If the script was cloned from a storage, wouldn't it still show up for all players in the game? That's my problem, I need the GUI to only show up for certain players in the group, but right now it's either all players or no players.
idk why, but the formatting for the code block is not working, the code is just an example, and probably not the best
Put the code block in between the tildes (~), not on the same line