I am making thing, so when player click GUIButton, they can see everyone’s leaderstats, while those people can’t. I made this script:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player then
local lb = player:FindFirstChildOfClass("Folder")
if lb then
lb.Name = "leaderstats"
end
end
end)
Problem with this script is that, when player click on that GUIButton, they can only see their stats
Its because you are only changing the local players foldername, so only the local player will have leaderstats. Instead, change this to:
local client = game.Players.LocalPlayer -- Not required for this
script.Parent.MouseButton1Click:Connect(function()
for _, player: Player in pairs(game:GetService("Players"):GetPlayers()) do
local lb = player:FindFirstChildOfClass("Folder")
if not lb then continue end -- No folder found, skip
if lb.Name == "leaderstats" then -- Toggle visibility
lb.Name = "hidden_leaderstats"
else
lb.Name = "leaderstats"
end
end
end)