You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make a player UI that updates when someone join
Story
the UI still works when someone joins, lets say that client 1 joins before client 2. Client 1 can see his avatar and name, but when client 2 joins he can see client 1 and 2 avatar but client 1 cant.
-
What is the issue? Include screenshots / videos if possible!
I can’t seem to get it to update the UI when someone else joins. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using a while true do but when the player joins the leaderboard copys the name 3 times.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Code
local Players = game:GetService("Players")
local AmountOfPlayers = #Players:GetPlayers()
local ServerStorage = game.ServerStorage
local TOuch = game:GetService("UserInputService").TouchEnabled
local Keyboard = game:GetService("UserInputService").KeyboardEnabled
local Gamepad = game:GetService("UserInputService").GamepadEnabled
local Player
local Player1
local Player2
local Player3
local Player4
local Player1ID
local Player2ID
local Player3ID
local Player4ID
local Cooldown = 10
function Update()
end
Players.PlayerAdded:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers + 1
game.ServerStorage.ServerSidedStorage.Users.Users.Value = AmountOfPlayers
if AmountOfPlayers == 1 then
game.StarterGui.Main.Frame.Client1.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
if Keyboard == true then
print("😀 Client 1 | ⌨ Keyboard Enabled / PC")
game.StarterGui.Main.Frame.Client1.Platform.Text = "⌨"
game.StarterGui.Main.Frame.Client1.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client1.Data.platform.Value.Value = 1
end
if TOuch == true then
print("Client 1 | Touch Enabled / Mobile")
game.StarterGui.Main.Frame.Client1.Platform.Text = "📱"
game.StarterGui.Main.Frame.Client1.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client1.Data.platform.Value.Value = 2
end
if Gamepad == true then
print("Client 1 | Gamepad Enabled / XBOX")
game.StarterGui.Main.Frame.Client1.Platform.Text = "🎮"
game.StarterGui.Main.Frame.Client1.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client1.Data.platform.Value.Value = 3
end
end
if AmountOfPlayers == 2 then
game.StarterGui.Main.Frame.Client2.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
if Keyboard == true then
print("😀 Client 2 | ⌨ Keyboard Enabled / PC")
game.StarterGui.Main.Frame.Client2.Platform.Text = "⌨"
game.StarterGui.Main.Frame.Client2.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client2.Data.platform.Value.Value = 1
end
if TOuch == true then
print("Client 2 | Touch Enabled / Mobile")
game.StarterGui.Main.Frame.Client2.Platform.Text = "📱"
game.StarterGui.Main.Frame.Client2.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client2.Data.platform.Value.Value = 2
end
if Gamepad == true then
print("Client 2 | Gamepad Enabled / XBOX")
game.StarterGui.Main.Frame.Client2.Platform.Text = "🎮"
game.StarterGui.Main.Frame.Client2.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client2.Data.platform.Value.Value = 3
end
end
if AmountOfPlayers == 3 then
game.StarterGui.Main.Frame.Client2.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
if Keyboard == true then
print("😀 Client 3 | ⌨ Keyboard Enabled / PC")
game.StarterGui.Main.Frame.Client2.Platform.Text = "⌨"
game.StarterGui.Main.Frame.Client3.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client3.Data.platform.Value.Value = 1
end
if TOuch == true then
print("Client 3 | Touch Enabled / Mobile")
game.StarterGui.Main.Frame.Client2.Platform.Text = "📱"
game.StarterGui.Main.Frame.Client3.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client3.Data.platform.Value.Value = 2
end
if Gamepad == true then
print("Client 3 | Gamepad Enabled / XBOX")
game.StarterGui.Main.Frame.Client2.Platform.Text = "🎮"
game.StarterGui.Main.Frame.Client3.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client3.Data.platform.Value.Value = 3
end
end
if AmountOfPlayers == 4 then
game.StarterGui.Main.Frame.Client2.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..Player.UserId.."&width=420&height=420&format=png"
if Keyboard == true then
print("😀 Client 4 | ⌨ Keyboard Enabled / PC")
Player.PlayerGui.Main.Frame.Client4.Platform.Text = "⌨"
game.StarterGui.Main.Frame.Client4.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client2.Data.platform.Value.Value = 1
end
if TOuch == true then
print("Client 4 | Touch Enabled / Mobile")
game.StarterGui.Main.Frame.Client2.Platform.Text = "📱"
game.StarterGui.Main.Frame.Client4.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client4.Data.platform.Value.Value = 2
end
if Gamepad == true then
print("Client 4 | Gamepad Enabled / XBOX")
game.StarterGui.Main.Frame.Client2.Platform.Text = "🎮"
game.StarterGui.Main.Frame.Client4.TextLabel.Text = Player.Name
ServerStorage.ServerSidedStorage.Users.Client4.Data.platform.Value.Value = 3
end
end
end)
Players.PlayerRemoving:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers - 1
game.ServerStorage.ServerSidedStorage.Users.Users.Value = AmountOfPlayers
end)
*this is in server storage / server script storage