Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use remote event to receive information?

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

✓ Accepted answer

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.

3 comments

1

You right, I will use PlayerAdded.

0

Indeed it will be better.

1

Yes

This discussion is preserved as it was. New answers, comments, and votes are closed.