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

How to use remote event to receive information?

Asked by
DAHUI84 25
2 years ago

Hello I want to know how I can use remote event to send information

-- script
local remote = game.ReplicatedStorage.RemoteEvent

local GAME_INFO = {}

remote:FireServer(GAME_INFO)

-- local script
local remote = game.ReplicatedStorage.RemoteEvent

local REMOTE_INFO

remote.OnServerEvent:Connect(function(info)
    REMOTE_INFO = info
end)

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

You did the opposite, when you are on a script and you want to fire the remote to the client you can use two methods.

:FireAllClients who fire all clients in the game. :FireClient who fire only one client and need for first argument the player instance.

To recieve information on the client side you need to use ÒnClientEvent and not OnServerEvent.

You can see the developer page who talk about RemoteEvents

If I answered your question you can Accept Answer and if you have any questions put them in the comments.

-- script
local remote = game.ReplicatedStorage.RemoteEvent

local GAME_INFO = {}

remote:FireAllClients(GAME_INFO)

-- local script
local remote = game.ReplicatedStorage.RemoteEvent

local REMOTE_INFO

remote.OnClientEvent:Connect(function(info)
    REMOTE_INFO = info
end)

Isn't the best structure to do but your code is fix.

1
You right, I will use PlayerAdded. DAHUI84 25 — 2y
0
Indeed it will be better. NiniBlackJackQc 1562 — 2y
1
Yes DAHUI84 25 — 2y
Ad

Answer this question