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

Why does JSONEncode return null?

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

✓ Accepted answer

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.

2 comments

0

Thanks, but I was hoping to find the other arguments that were possibly inputted

0

Other arguments that were inputted without writing them manually*

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