I know how to send a signal for a localscript to a script with remote events, but I don't know how do we do the inverse.
Any answers will be accepted if it's working! Thanks
Ok, guys now I know how, but how can we send a name in this signal?
Remote Events are designed to provide a one way message between the server and clients. This message can be directed from one client to the server, from the server to a particular client, or from the server to all clients.
On the server, you'll take the RemoteEvent and give it the logic
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent RemoteEvent:FireClient()
When working with Remotes you can additionally add conditionals to trigger when the remote is fired. This is good for many functions. Here is a good example of it:
if money > price then RemoteEvent:FireClient() end
Something to notice is that you need a Player Parameter to initiate to which client to run the script to. This can be the most difficult part of the code but there are several methods.
Method 1: PlayerAdded
game.Players.PlayerAdded:Connect(function(plr) RemoteEvent:FireClient(plr) end)
Method 2: GetPlayerFromCharacter() If you have a player's character model (the physical model), you can find the corresponding Player instance for that character (the object in the Players service which has GUIs and the StarterGear and PlayerPack). Read more an the wikia article here: Roblox Developer Hub
Method 3: Fire All Clients If you would like to fire a signal to the Clients from a server script(or so you call script to local script signal) there is a more viable option.
FireAllClients() FireAllClients is used if you would like to run the code for all clients which does not require a player parameter Here is an example:
if plrs >= 7 then RemoteEvent:FireAllClients() end
The FireAllClients() will execute the remote for all of the players(client) in the game currently and is an extremely useful function.
There are several other methods to recieve the player but since you are new I recommend either using FireAllClients() or PlayerAdded() methods/events to get the player. (use Example one that I gave you)
Finally, you controll what happens in the code with your OnClientEvent(). Just like OnServerEvent(), this method allows you to controll how the client (LocalScript) responds to the sent signal.
LocalScript
game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function() --code end)
Hope this helped (: