RemoteEvent
✏ Beginners Scripting Guide ✏
SERVER USAGE
Client
local players = game:GetService('Players')
local replicatedStorage = game:GetService('ReplicatedStorage')
local myRemote = ReplicatedStorage:WaitForChild('MyRemote')
-- Communicate the server from the client by using :FireServer() and pass in data to send to the server from the client.
myRemote:FireServer('This is a client message')Server
local players = game:GetService('Players')
local replicatedStorage = game:GetService('ReplicatedStorage')
local myRemote = ReplicatedStorage:WaitForChild('MyRemote')
myRemote.OnServerEvent:Connect(function(player, data)
-- Received a message from the client and triggered the block code below.
-- The first argument of OnServerEvent is always a local player.
print(data) -- This will print "This is a client message"
end)CLIENT USAGE
Server
Client
ALL CLIENTS USAGE
Server
Client
Last updated