I’m a somewhat beginner to scripting and I’ve recently been learning about how to use remote events and functions, however I’m not sure what to put inside the parenthesis when firing the event/function. Can someone explain what arguments need to be passed, and perhaps an example of this being used?
3 Likes
You can pass any agruements such as strings, numbers, etc.
3 Likes
Keep in mind that you do not have to have a player argument when doing :FireServer()
. When connecting to .OnServerEvent(), the first argument will be the player firing the event.
2 Likes
How can this be used? Would you mind giving a simple example so I can better understand the concept?
1 Like
Script in ServerScriptService:
local rs = game:GetService("ReplicatedStorage");
local remote = rs:WaitForChild("RemoteEvent");
remote.OnServerEvent:Connect(function(player, argA, argB, argC)
print(player.UserId, typeof(argA), typeof(argB), typeof(argC))
end)
LocalScript in StarterGui:
local rs = game:GetService("ReplicatedStorage");
local remote = rs:WaitForChild("RemoteEvent");
remote:FireServer("string", 1234, workspace.Part)
Expected output:
Anything changed in the client will not be replicated into the server unless passed through as an argument.
2 Likes
Thanks for the example, I see that they are similar to normal parameters.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.