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

Why does JSONEncode return null?

Asked by 4 years ago
Edited 4 years ago
local tupleArg = http:JSONEncode(...)

I want to get the arguments from my FireServer Function without manually placing the arguments (checking multiple events to see if one was fired), but it always prints null, how can I accomplish getting the arguments for the certain event?

Note: This is all inside of an OnServerEvent function

1 answer

Log in to vote
1
Answered by 4 years ago

You can place arguments in the Event:FireServer(). When you are writing up your OnServerEvent function, be aware that the player that fired the server is listed before your arguments. Event.OnServerEvent(plr, arguments).

So lets say you want to transmit the letter x from the client to the server for your encode.

--This is from the client.
local var = "x"

game.ReplicatedStorage.RemoteEvent:FireServer(var)

Now for the server.

--This is from the server.
game.ReplicatedStorage.RemoteEvent.OnServerEvent(function(player, var)

print(var) --Output: "x"

end)

Hope this answered what you were looking for.

0
Thanks, but I was hoping to find the other arguments that were possibly inputted zboi082007 270 — 4y
0
Other arguments that were inputted without writing them manually* zboi082007 270 — 4y
Ad

Answer this question