It appears you are attempting to do this through a local script. I suggest using game.Players.LocalPlayer rather than game.Players.PlayerAdded. Also, this is intended for anyone UNDER the rank of 45, correct?
Well yes I am doing it by localscript, since its a gui script. And I messed up, I wanted like players that that have the rank value equal or bigger than 45.
Judging by the way this script is written, I would assume that you are using this in a LocalScript to make something visible. The reason why you aren’t encountering any errors is because this code will work, but only for when other players join. LocalScripts run far after the LocalPlayer connects to the server, so this is just a timing issue. Use the LocalPlayer instead.
local LocalPlayer = game:GetService("Players").LocalPlayer
if LocalPlayer:GetRankInGroup(5772804) < 45 then
script.Parent.Frame.Visible = true
script.Parent.Shadow.Visible = true
script.Parent.TextLabel = true
end
Yes you are correct I am using a local script to make it appear for workers only, and since it would be easier to manage that’s why I’ve made it a localscript.
The code you provided wouldn’t work considering the fact that this seems to be a BillboardGui inserted into the characters Head. What you could do is find the player from their character, it’s pretty easy once you get it down, but it’s hard thinking about it at first.
Considering that this is a Script and not a LocalScript, your class hierachy should look like: StarterPlayer -> StarterCharacterScripts -> GUIInserterScript -> RankGUI
We can use the power of game:GetService("Players"):GetPlayerFromCharacter() to grab our Player.
Finally, here’s some guiding “code” to help you finish the rest.
local Players = game:GetService("Players")
local char = script.Parent
local ourPly = Players:GetPlayerFromCharacter(char)
-- fill in ur behavioral code like the "IsRankInGroup" stuff
-- by the way, you should store your BillboardGui
-- inside of the script, and call :Clone() on it when a player
-- has met your requirements to have a rank gui.
You need to use a script for this by the way, so everyone can see it.
EDIT:
When I mean “script” I mean the Script object, not the LocalScript object.