How to pass player name when a remote event is fired twice with a different way?

Hello Devs! This is my second topic and i got a proplem today that i think iam a bit stupid in, so basically i got a script that whenever a button is pressed it fires for all players and clones the gui and etc , among the gui there is a text label that the player name should be but the name is only the local player’s name and i want it to be for the player who fired the remote event first so i made a remote event and everything but the proplem is that i had to fire the server first then fire all clients i did that well but i cant pass the name of the player throught the firing of all clients only the server here is the part of the script that fires the server(its a local script)


script.Parent.Ready.MouseButton1Click:Connect(function()
	
	game.ReplicatedStorage.Recieve:FireServer()
end)

and here is the script that gets the signal of the server firing and the one that fires all the clients(a regular script)


game.ReplicatedStorage.Recieve.OnServerEvent:Connect(function(plr)

	game.ReplicatedStorage.Recieve:FireAllClients()

end)

as you can see the player name only reaches this script but not the other that handles the gui, if u want the script that receives the all players firing just mention me.
Hope yall have a good day :smile:

Try passing plr.Name as an argument in the FireAllClients event.

but how am i going to define it in the script that is going to recieve the name?

RemoteEvent.OnClientEvent:Connect(function(PlayerName) --Do code here end)

The same way any ordinary function receives arguments.

On the Local Script that will receive the FireAllClients signal, just use the player who pressed the button’s name which you passed down as an argument.

i cant do that bec the code is done in a local script

‘OnClientEvent’ is a client event/signal. Don’t get confused by its name.

sry but i dont understand how am i going to do that

Of course you can?

You used FireAllClients on a server script, just follow @Forummer’s method in a Local Script that will receive the signal.

Create a Local Script that will receive the signal and just have your code there.

game.ReplicatedStorage.Recieve.OnClientEvent:Connect(function(playername)
    -- your code here, playername is the name of the player who clicked the button that was converted as a string
end)

i still dont understand how will it get the playername and where, do u mean like from the regular script?

You got the playername argument in the server script from the OnServerEvent which returned you by default the player who fired the event, you then pass down the name of that player to all clients through the “playername” argument.

yeah okay i understand now so i dont change anything here?


 game.ReplicatedStorage.Recieve.OnServerEvent:Connect(function(plr)

	game.ReplicatedStorage.Recieve:FireAllClients(plr.Name)

end)

That should be good, now go on your Local Script that will receive the signal through OnClientEvent and you should have the player who clicked the button’s name as an argument.

so like if i want to pass the player i just remove the .Name right? in the regular script?

Yes, just pass down “plr” and the Instance of the player will be passed down.

okay i will test and tell you thanks for the help!

Thanks it actually worked! i didnt know that