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
--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.

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

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.

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:

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.

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