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
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!
That also won't work, GUIs are cloned into the PlayerGui locally, essentially making them inaccessible to the server
not working
local Players = game:GetService("Players") function onPlayerRemoving(plr) local nm = Players:GetPlayerFromCharacter(plr.Parent) for i,v in pairs(Players:GetPlayers()) do v.PlayerGui.teleport.sword.Text = nm.Name wait(3) v.PlayerGui.teleport.sword.Text = "" end end) Players.PlayerRemoving:Connect(onPlayerRemoving) i wrote this in server script service but...
tnt why not make a remote event
ok I remade it
you do know that PlayerRemoving works on the client side, right?
yeah but im too lazy to change my answer again
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
you're using startergui instead of playergui. Also, is this a local script or a server script?
server script... if i put it into the gui it will wotk? and make it local script?