Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

--Server script

rs = game:GetService("ReplicatedStorage")
admins = {"LawlR", "gungirl60"}
game.Players.PlayerAdded:Connect(function(plr)
	for _,a in pairs(admins) do
		if plr.Name == a then
			rs:FindFirstChild("adminjoined"):FireAllClients()
		end
	end
end)
--Local script, ignore all of the function..

text1 = script.Parent.Parent.t1
text2 = script.Parent.Parent.t2
text3 = script.Parent.Parent.t3
text4 = script.Parent.Parent.t4
text5 = script.Parent.Parent.t5
text6 = script.Parent.Parent.t6
text7 = script.Parent.Parent.t7
rs = game:GetService("ReplicatedStorage")


function adminjoined()
	script.Parent.Parent.Parent.Enabled = true
	repeat wait (.02) text1.TextTransparency = text1.TextTransparency + .03 until text1.TextTransparency >= 1
	repeat wait (.02) text2.TextTransparency = text2.TextTransparency + .03 until text2.TextTransparency >= 1
	repeat wait (.02) text3.TextTransparency = text3.TextTransparency + .03 until text3.TextTransparency >= 1
	repeat wait (.02) text4.TextTransparency = text4.TextTransparency + .03 until text4.TextTransparency >= 1
	repeat wait (.02) text5.TextTransparency = text5.TextTransparency + .03 until text5.TextTransparency >= 1
	repeat wait (.02) text6.TextTransparency = text6.TextTransparency + .03 until text6.TextTransparency >= 1
	repeat wait (.02) text7.TextTransparency = text7.TextTransparency + .03 until text7.TextTransparency >= 1
	repeat wait (.02) text7.Parent.BackgroundTransparency = text7.Parent.BackgroundTransparency + .03 until text7.Parent.BackgroundTransparency >= 1
	script.Parent.Parent.Parent.Enabled = false
	text1.TextTransparency = 0
	text2.TextTransparency = 0
	text3.TextTransparency = 0
	text4.TextTransparency = 0
	text5.TextTransparency = 0
	text6.TextTransparency = 0
	text7.TextTransparency = 0
end

event = rs:WaitForChild("adminjoined")
event.OnClientEvent:Connect(adminjoined)

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.

4 comments

0

Parameters: Player (Required)

0

Are you trying to fire all clients or a certain player?

0

Where?

0

Yeah I changed it to all clients.

2 answers

✓ Accepted answer

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

ServerScript

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

LocalScript

local function adminjoined(plr) --plr can be named anything
	--All the function things
end


event.OnClientEvent:Connect(adminjoined)

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

4 comments

0

Thanks.

0

Never mind. It only shows for the admin. Other players get an error saying "attampt to index local 'plr' (a nil value)".

0

Never mind never mind, I just needed to make it wait for the character for some reason. Thanks again.

0

No problem!

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

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

or

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

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

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.