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

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

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

remote:FireServer(plrname)

1 comment

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.

1 answer

✓ Accepted answer

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!

1 comment

0

Thank you for the help!

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