I want to add the players name and avatar to ui for whole server if they have clicked play. Similar to Piggy. Here is some of my code below. Has anyone done this before. I know that I have to use a RemoteEvent but need help with starting the server script.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local ServerScriptService = game:GetService("ServerScriptService")
local Settings = ReplicatedStorage:WaitForChild("Settings")
local MainMenuModule = require(game.ReplicatedStorage.Modules.MainMenuModule)
local inRoundBoolValue = Settings.serverInRound
inRoundBoolValue.Value = nil
local serverOnMainMenu = Settings.serverOnMainMenu
local PlayerInfoEvent = script.Parent.SendPlayerInfo
local MainMenuGui = script.Parent
local Background = MainMenuGui.Background
local PlayButton = MainMenuGui.Play
local ShopButton = MainMenuGui.Shop
PlayButton.MouseButton1Up:Connect(function()
PlayerInfoEvent:FireServer(Player.UserId)
MainMenuGui.PlayersFrame.Visible = true
MainMenuModule.CreatePlayerForPlayersFrame(Player)
end)
local module = {}
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local MainMenuScreenGUI = PlayerGui:WaitForChild("MainMenu")
local PlayButton = MainMenuScreenGUI:WaitForChild("Play")
local ShopButton = MainMenuScreenGUI:WaitForChild("Shop")
local PleaseWait = MainMenuScreenGUI:WaitForChild("PleaseWait")
local PlayersFrame = MainMenuScreenGUI:WaitForChild("PlayersFrame")
local ScrollingFrame = PlayersFrame:WaitForChild("ScrollingFrame")
local Template = ScrollingFrame:WaitForChild("Template")
function module.CreatePlayerForPlayersFrame()
for _, Player in Players:GetPlayers() do
local Tem = Template:Clone()
Tem.Parent = ScrollingFrame
Tem.Visible = true
local ImageLabel = Tem:WaitForChild("ImageLabel")
local userId = Player.UserId
Tem.TextLabel.Text = Player.Name
local thumbType = Enum.ThumbnailType.AvatarBust
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
ImageLabel.Image = content
print("got player".. Player.Name)
end
end
return module