How to send Number.Value to Server with Remote Event/Function

Hello, The title is the question really.

I would like to send a number.value to leaderstats (server side) with a remote event or function (not sure which)

and how would i pick up the sent number on the server side.

Thanks

1 Like

You should use a RemoteEvent instead of a RemoteFunction if you’re just sending information over.

As stated on the wiki, RemoteEvents are designed for one-way communication, while RemoteFunctions are designed for two-way communication, where the sender expects to receive a response.

When you send Remotes, you can pass information through the arguments like you would with any other function.

-- send remote from client to server
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent:FireServer(number.Value) -- pass number value argument
-- server receives remote
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(player, numberVal) -- player argument is automatically passed from the client. Second argument is your variable that you passed
    print(player.Name .. "'s number value is " .. numberVal) -- do something with that information
end)
14 Likes

on the function part of the remote event you just do:

remoteevent.OnServerEvent:Connect(function(player, number)

Thank you so much, Thats Mint !!

1 Like