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

How do you pass a parameter from a localscript to the serverscript using a remote event??

Asked by 5 years ago
Edited 5 years ago

I tried like this but I'm not getting the parameter in the server script.

remote:FireServer(plrname)
1
'Cast' is the wrong terminology. Casting is when you convert one datatype to another. I believe you're looking for 'pass'. The first parameter of OnServerEvent will be the player who fired the event. So argument 'plrname' will end up being the 2nd parameter. pidgey 548 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Hi, this is an example of passing arguments using events:

--||LocalScript||--
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") --Change this to where your remote is

remote:FireServer(2)

--||ServerScript||--
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") --Change this to where your remote is

remote:OnServerEvent:Connect(function(playerWhoFiredEvent, number)
    print(number) --This will print 2
end)

From this example, I believe you now know how to pass arguments from LocalScript to ServerScript.

Hope this helps!

0
Thank you for the help! Freddan2006YT 88 — 5y
Ad

Answer this question