Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get the player that just joined's name in a local script from FireAllClients()?

Asked by
LawlR 182
6 years ago
Edited 6 years ago
01--Server script
02 
03rs = game:GetService("ReplicatedStorage")
04admins = {"LawlR", "gungirl60"}
05game.Players.PlayerAdded:Connect(function(plr)
06    for _,a in pairs(admins) do
07        if plr.Name == a then
08            rs:FindFirstChild("adminjoined"):FireAllClients()
09        end
10    end
11end)

-

01--Local script, ignore all of the function..
02 
03text1 = script.Parent.Parent.t1
04text2 = script.Parent.Parent.t2
05text3 = script.Parent.Parent.t3
06text4 = script.Parent.Parent.t4
07text5 = script.Parent.Parent.t5
08text6 = script.Parent.Parent.t6
09text7 = script.Parent.Parent.t7
10rs = game:GetService("ReplicatedStorage")
11 
12 
13function adminjoined()
14    script.Parent.Parent.Parent.Enabled = true
15    repeat wait (.02) text1.TextTransparency = text1.TextTransparency + .03 until text1.TextTransparency >= 1
View all 34 lines...

How do I get the player's name that just joined? I would like to change the text to "(player that just joined) had joined" or something along those lines, but I'm not sure how to get the name.

0
Parameters: Player (Required) supermariodeadtolive 55 — 6y
0
Are you trying to fire all clients or a certain player? DogeDark211 81 — 6y
0
Where? LawlR 182 — 6y
0
Yeah I changed it to all clients. LawlR 182 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

If you want to give the player name to the clients, you can do the following:

ServerScript

1rs:FindFirstChild("adminjoined"):FireAllClients(plr) --The plr variable has already been created

LocalScript

1local function adminjoined(plr) --plr can be named anything
2    --All the function things
3end
4 
5 
6event.OnClientEvent:Connect(adminjoined)

Hopefully this helps. If you have any problems please tell.

0
Thanks. LawlR 182 — 6y
0
Never mind. It only shows for the admin. Other players get an error saying "attampt to index local 'plr' (a nil value)". LawlR 182 — 6y
0
Never mind never mind, I just needed to make it wait for the character for some reason. Thanks again. LawlR 182 — 6y
0
No problem! Creeperman1524 120 — 6y
Ad
Log in to vote
0
Answered by
valchip 789 Moderation Voter
6 years ago
Edited 6 years ago

I am not sure what you mean. I will just give you 2 examples which may be what you want:

1local plr = game.Players.LocalPlayer
2print(plr.. "has joined the game.")

or

1game.Players.PlayerAdded:Connect(function(plr)
2    print(plr.." has joined the game."
3end

If you wanna do this in client you may want to use the first examples.

0
What I want is that when a player than is an admin joins the server, all the players get a gui message on their screen saying that the player has joined, but I'm not sure how to get the player's that just joined name. LawlR 182 — 6y

Answer this question