Playerlist not working!

Been looking into this for around an hour; I’m relatively new to roblox dev-forum and I’m not exactly sure how to check up on new studio updates and changes.

Last night I coded a player-list with User-profile, rank and username all worked fine. this evening when I started to further develop it, it just doesn’t work, no outputs nothing, as I mentioned above it worked perfectly like last, and now no changes made it’s not working! sorry for the repetitiveness

here is my script for reference!

local Parent = script.Parent
local ClickSound = Parent.Click
local Group = 15777400
local MinStaffRank = 100

local HttpService = game:GetService("HttpService")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Event = ReplicatedStorage.Events.StaffPlayerList
local CommsFrame = Parent.CommsFrame
local StaffList = CommsFrame.PlayerList.StaffList
local PlayerTemplate = CommsFrame.PlayerList.PlayerTemplate

function OnPlayerJoined()
	Event.OnClientEvent:Connect(function(Player,Rank,MinRank)
		for _,Staff in pairs(Players:GetChildren()) do
			PlayerTemplate:Clone()
			if MinRank then return end
			PlayerTemplate.User.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Staff.userId.."&width=420&height=420&format=png"
			PlayerTemplate.Username.Text = Staff.Name
			PlayerTemplate.Rank.Text = Rank
			PlayerTemplate.Parent = StaffList
		end
	end)
end

you are cloning the player template but not storing it as a variable so you are only modifying a single player template every time

hiya! I don’t quite understand; sorry if it’s a pain to explain but do you mind elaborating!
thank you though!

function OnPlayerJoined()
	Event.OnClientEvent:Connect(function(Player,Rank,MinRank)
		for _,Staff in pairs(Players:GetChildren()) do
			local new = PlayerTemplate:Clone()
			if MinRank then return end
			new.User.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Staff.userId.."&width=420&height=420&format=png"
			new.Username.Text = Staff.Name
			new.Rank.Text = Rank
			new.Parent = StaffList
		end
	end)
end

should be something like this since the :Clone() function returns the clone so you store it as a variable

omg thank you so much I’ll try it now!

Hi again, my problem wasn’t that it was just that when I test it nothing happens, the template stays the same, it’s parent isnt the staff list, and the profile nor the name nor the rank changes!

did you connect the onplayerjoined function to a player joining like

Players.PlayerAdded:Connect(OnPlayerJoined)

that does not appear to be the problem.

Well you put your Remote event code inside of OnPlayerJoined - it should be outside of it since you only need to do it once since it works for every player - and is the event being fired?
edit - realized it was client and also what is the point of putting player for the event when you make a clone for every player in the game?

The event has been fired through a server script yes.
edit - I added it as I was previously using it but I just didn’t take it out of the variables.

is MinRank a true boolean or an object because then it will never go through

MinRank was a variable which I used in my serverscript to get the minimum rank for the template to clone it

I get the a studio error “Attempt to connect failed: Passed value is not a function”, I’m not sure what it means!
Again sorry if I’m being a pain I have quite bad anxiety (I’m not trying to guilt-trip you)

im pretty sure that “Attempt to connect failed: Passed value is not a function” comes when you conenct a function like

Players.PlayerAdded:Connect(OnPlayerJoined())

instead of

Players.PlayerAdded:Connect(OnPlayerJoined)

you dont put the parentheses because the thing you are connecting to will put in the variables

No, I have used

 Players.PlayerAdded:Connect(OnPlayerJoined)

edit - I fixed the error but It hasn’t fixed my UI

is the frames and stuff inside a ScreenGui and is that ScreenGui enabled?

Yes, everything is enabled. It may have something to do with my serverscript it’s the only other script that has an impact on the UI

after a little testing if you put a PlayerAdded connection it wont fire for yourself it will only fire when other players join

Oh that would make sense, is there any way to fix it?

function OnPlayerJoined()
       stuff when someone joins
end

Event.OnClientEvent:Connect(function(Player,Rank,MinRank)
	for _,Staff in pairs(Players:GetChildren()) do
		PlayerTemplate:Clone()
		if MinRank then return end
		PlayerTemplate.User.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Staff.userId.."&width=420&height=420&format=png"
		PlayerTemplate.Username.Text = Staff.Name
		PlayerTemplate.Rank.Text = Rank
		PlayerTemplate.Parent = StaffList
	end
	end)

you just move it out of the playerjoined function