game.Players.PlayerRemoving:Connect(function(plr) nm = game.Players:GetPlayerFromCharacter(plr.Parent) game.StarterGui.teleport.sword.Text = nm.Name end)
i want to show people on gui who leaves the server but its not working
New answer: The reason why it was NOT working was because I forgot that remote events existed. My bad lol
SERVER SCRIPT
local Players = game:GetService("Players") local PlayerLeft = game:GetService("ReplicatedStorage").PlayerLeft function onPlayerRemoved(Player) PlayerLeft:FireAllClients(Player) end Players.PlayerRemoving:Connect(OnPlayerRemoved)
CLIENT SCRIPT
local Text = script.Parent local PlayerLeft = game;GetService("ReplicatedStorage").PlayerLeft function onPlayerLeftFired(Player) Text.Text = Player.Name.." left the game!" wait(3) Text.Text = "" end PlayerLeft.OnClientEvent:Connect(onPlayerLeftFired)
In the setup above we're going to need to have a remote event in ReplicatedStorage called "PlayerLeft". We'll then make the server script in the code above be in ServerScriptService. We'll have the client script in the textlabel you've created (assuming you've made one). That's all!