I tried like this but I'm not getting the parameter in the server script.
remote:FireServer(plrname)
I tried like this but I'm not getting the parameter in the server script.
remote:FireServer(plrname)
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!
Thank you for the help!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
'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.