so i was making a custom player list , i need to see if it’s working or not but i can’t test it in studio . so can somebody tell me if this is working ? It’s my first time making custom player list all by myself , so i can’t guarantee it will work .
Local Script -
--Label , Frame , Name
local Frame = script.Parent.Frame -- the player list
local label = script:WaitForChild("TextLabel") -- player name that will be in the frame later
local plrName = game.Players.LocalPlayer.Name
--Remote Event
local event = game.ReplicatedStorage.RemoteEvent
event:FireServer(label, plrName, Frame)
Server Script -
local event = game.ReplicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(player, label, plrName, Frame)
local newLabel = label:Clone()
newLabel.Parent = Frame
newLabel.Text = plrName
end)
1 Like
You can start a local server with 0 ~ 8 players in studio here
i can’t do that , my pc will crashed
1 Like
You could change your script to work with a fake list of players instead of real players. E.g. change your local script to this:
--Label , Frame , Name
local Frame = script.Parent.Frame -- the player list
local label = script:WaitForChild("TextLabel") -- player name that will be in the frame later
--Remote Event
local event = game.ReplicatedStorage.RemoteEvent
local fakePlayers = {
"TestPlayer1",
"TestPlayer2",
"TestPlayer3",
}
for _, playerName in pairs(fakePlayers) do
event:FireServer(label, playerName, Frame)
end
Although you’d probably need to create labels and frames in the LocalScript as well with this approach. Speaking of which, why are you using a RemoteEvent for this instead of just having each player maintain their own player list without any involvement from the server?
because i thought if i use remote event , then every player can see it .
why do u need remotevent, just put localscript into individual players thus making the client handle it as it should be.
It’s true that if one player makes a change that any other player should be able to see, you need to involve the server by using a RemoteEvent. But in this situation, it’s quite a bit simpler to just let every player maintain their own player list. Player B doesn’t need to know how player A’s list looks, because player B has their own list that is completely separate. All the information needed to create and maintain the list is available to players. They can look up which players are in the game using Players:GetPlayers, and can update the list when players leave or join with Players.PlayerRemoving and Players.PlayerAdded.
If you need more info, like kill count, you must make that info available to the players somehow. If you’re using e.g. IntValues for kill counts, and if those IntValues are stored somewhere that is replicated to clients, then the player lists can look at those IntValues to stay up to date. Or you can use a RemoteEvent that fires every time kill counts change. Either way is fine.
1 Like