I have been trying to get the hang of FilteringEnabled for weeks and I am really starting to get agitated. Based on my understanding, with it on, the client cannot access the Workspace; only client-related information can be accessed by the client, such as the PlayerGui. If my understanding is correct, then I simply cannot see any reason why this leaderboard script does not work.
I want to make a custom leaderboard for my game; in my game, a maximum of 12 players can play at a time. My leaderboard is supposed to display the player's name, his or her level, and, if he or she is in prestige mode, an icon shows next to their name that displays their prestige level. (If you've ever played Call of Duty multiplayer, this should seem familiar to you) This is how my leaderboard is set out: a ScreenGui in the StarterGui holds a Frame which holds 12 more frames named 1 through 12, each with an ImageLabel named Prestige, a TextLabel named Player, and another TextLabel named Level.
Inside of the Frame within the Frame is a script which does all of the magic. When I test this script on a server, it does not work at all. No error is returned; the leaderboard is blank and nothing happens. When I turn FilteringEnabled off, it works exactly as it should. I have no clue as to why.
This is the script.
while wait(.1) do
player = script.Parent.Parent.Parent.Parent --Getting the player
gui = player.PlayerGui --Getting the player's PlayerGui
if player.Stats then --Upon joining the game, the game should create a folder named "Stats" which holds the player's Level and Prestige. If it has not been created yet, then this will not work.
playerLevel = player.Stats.Level --Getting the player's Level
playerPrestige = player.Stats.Prestige --Getting the player's Prestige
if playerPrestige.Value < 1 then --If the player has no Prestige, the name will shift all the way to the left and no image will be shown.
script.Parent[1].Prestige.Image = ""
script.Parent[1].Player.Position = UDim2.new(0, 0, 0, 0)
else --If there is, the name will shift over by 20 to give room to the 20x20 image that will display the Prestige icon.
script.Parent[1].Player.Position = UDim2.new(0, 20, 0, 0)
if playerPrestige.Value >= 10 and playerLevel.Value >= 50 then --10 is the maximum Prestige and 50 is the maximum Level; if the player meets this criteria, he or she gets the Master Prestige icon.
script.Parent[1].Prestige.Image = gui.Prestige.Master.Value
else
findIcon = gui.Prestige:FindFirstChild(playerPrestige)
if findIcon then
script.Parent[1].Prestige.Image = findIcon.Value
end
end
end
script.Parent[1].Player.Text = " " ..player.Name --Adding a space at the start because I thought the text looked a little too close to the edge of the leaderboard.
script.Parent[1].Level.Text = playerLevel.Value
players = game.Players:GetChildren() --Getting all of the players
script.Parent.Size = UDim2.new(0, 200, 0, 20*#players+20) --Depending on how many players there are, the leaderboard will adjust its size. The frame has ClipDescendants on, so when it shortens, the other lines are obscured.
if #players > 1 then --If there is only one player, none of this is necessary.
t = 1
for i = 1, #players do
if players[i].Name ~= player.Name then
t = t + 1 --This is because we don't want a player's name to be inserted in the first line, as the main player already occupies it.
line = script.Parent:FindFirstChild(t)
line.Player.Text = " " ..players[i].Name
stat = players[i]:FindFirstChild("Stats") --Doing the same as we did with the main player.
if stat then
level = stat.Level
prestige = stat.Prestige
if prestige.Value < 1 then
line.Prestige.Image = ""
line.Player.Position = UDim2.new(0, 0, 0, 0)
else
line.Player.Position = UDim2.new(0, 20, 0, 0)
if prestige.Value >= 10 and level.Value >= 50 then
line.Prestige.Image = gui.Prestige.Master.Value
else
findIcon2 = gui.Prestige:FindFirstChild(prestige.Value)
if findIcon2 then
line.Prestige.Image = findIcon2.Value
end
end
end
line.Level.Text = level.Value
end
end
end
end
end
end
I've scanned through this script so many times and I've not been able to locate one instance of the script breaching past the Client spectrum. Based on what I have read about FilteringEnabled, this script should work perfectly. I really want to make my game as exploiter-free as possible, but by this point, I'm thinking about not using FilteringEnabled at all as it just doesn't make any sense to me why this isn't working.
Please help me figure out why this isn't working and make my headache go away ;-;

4 comments
If this local script is in the StarterGui, on line 2 try using player = game.Players.LocalPlayer
Wow... that actually worked.
Thank you!!! :D
You were locating the StarterGui. If you are using a LocalScript, finding the player is easier. game.Players.LocalPlayer. :D