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

How do I check when a RemoteEvent has been fired?

Asked by 4 years ago

I have never really understood how events work and now I need to use them and I have no idea how to check for when an event has been fired.

When Intermission ends in my main script, I want music to play which will be controlled from another script. It will call the function and the function is literally just:

game.ReplicatedStorage.IntMusic:FireServer()

But how to check when that has been fired in another script?

0
Do you have the remote event in the replicated storage? spot6003 64 — 4y
0
i don't think there's a way to check if a specific remote has been fired, but if you want to reduce the times a remote can be fired with debounce 0msh 333 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

If i am correct i believe you want to listen for the the remote being fired in a script.

If you wanna fire a remote from client to script and let the script receive that request then you would have to create a script, and add this code.

game.ReplicatedStorage.RemoteEventTest.OnServerEvent:Connect(function(player, argument)

end)

What this is basically doing is listening for when a specific remote is fired, it takes the player who fired the remote, as the first argument automatically. The second one being the argument you passed in the localscript. You can then add code inside that Event and do what you desire. The single argument you passed would be the second argument in this event, the first one is the player.

Ad
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

First lets learn what remote events are remote events are basically, events which you can only access from server to client or client to server.

To learn more visit:https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

Some actions can only be performed by a server and other actions only by a client. For example, a player (client) may activate a GUI button, upon which the server needs to enact a game-wide change. In these cases, a RemoteEvent or RemoteFunction lets server-side Scripts and client-side LocalScripts communicate with each other.

THIS Basically means that you can call an event from a local script to a server using the :InvokeServer remember this must be in a localscript

When using a inbuilt function Like :InvokeServer or :FireServer you must connect it to a remote event like this

Make sure this is in a localscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")

local clientPart = Instance.new("Part")
clientPart.Parent = workspace

remoteEvent:FireServer(clientPart)

Secondly, you must make sure you have a listener this is so the server knows that you want to make a request

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, argument)
-- put whatever you need
end)

Answer this question