Local script
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote") local remote2 = repStorage:WaitForChild("Remote2") local player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Parent.Joined.Visible = true script.Parent.Parent.Parent.ServerList.Visible = false if game.StarterGui.Menu.Joined.Name1.Text == "" then remote:FireServer() else if game.StarterGui.Menu.Joined.Name2.Text == "" then remote2:FireServer() else game.StarterGui.Menu.ServerList.Full.Visible = true wait(2) game.StarterGui.Menu.ServerList.Full.Visible = false end end end)
Server script (Workspace)
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote") local remote2 = repStorage:WaitForChild("Remote2") remote.OnServerEvent:connect(function() game.StarterGui.Menu.Joined.Name1.Text = game.Players.LocalPlayer.Name -- I don't know how to get the players name who clicked the Textbutton? game.StarterGui.Menu.ServerList.Name1.Text = game.Players.LocalPlayer.Name end) remote2.OnServerEvent:connect(function() game.StarterGui.Menu.Joined.Name2.Text = game.Players.LocalPlayer.Name game.StarterGui.Menu.ServerList.Name2.Text = game.Players.LocalPlayer.Name end)
The first argument sent via remotes is the player's player instance. This is the only trustworthy argument from the client with regards to remotes, as it's verified by the player's authentication-token, so players can't pretend to be someone else. The player parameter is passed implicitly, meaning that with this code client-side:
RemoteEvent:FireServer("A string!")
You could handle it like this server-side:
RemoteEvent.OnServerEvent:Connect(function(Player, SpecialString) print(Player.Name .. " sent us the string: " .. SpecialString) end)
In this case, remotes are besides the point. You're modifying game.StarterGui
and trying to modify the GUIs server-side. It's important to remember three things:
game.StarterGui
.game.StarterGui
is merely the template for GUIs to be cloned from into Player.PlayerGui
. Modifying it probably isn't what you want.I recommend setting the ScreenGui.ResetOnSpawn
property of this GUI to false. After that, you'd want to use RemoteEvent
s to inform all other players of changes to GUIs that you would want to make. You could use the game.Players.PlayerAdded
event client-side if you want to modify a GUI whenever a player joins the game.
RBXScriptSignal:connect()
is deprecated, you should prefer RBXScriptSignal:Connect()
.