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

How do I fire a remote event from ServerScriptService to a local script?

Asked by 3 years ago

I have a script in ServerScriptService and I need it to fire a remote event that a local script will get so that it can know to change a GUI element.

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can use :FireClient() to fire an event to a specific player

game:GetService("ServerScriptService").RemoteEvent:FireClient(player)
--Wherever the remote event is

The first parameter MUST be a player object in order for it to work

0
Also use RemoteEvent.OnClientEvent:Connect(function() to listen for the event to fire. R_alatch 394 — 3y
0
Lmao Ziffixture 6913 — 3y
Ad
Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
3 years ago

To appropriately engage this, you must establish a medium in which both ends of the network can access. The commonplace for RemoteEvent's is ReplicatedStorage when hoping to communicate between the Client & Server.

If you already have an existing Remote designated within ServerScriptService, this will need to be moved as this container is inaccessible to the Client.


As usual, we use the :FireClient() method to send our data, subsequently using the .OnClientResponse signal to receive.

Answer this question