✓ Accepted answer
well your code doesn't seem to be in a straight hierarchy. on line 6 you did http:JSONEncode()withHookData, but HookDatais defined on line 8 aslocal.. so will have to either move HookData = http:JSONEncode(HookData)` below where the HookData Object on line 8 is defined
or
define the HookData object as global, this way so its defined first(Global variables are defined first, if I remember right)
EDIT
ALSO, HTTP can only send numbers, and strings(text), and nothing else. That's why you need to call http:JSONEncode() to turn the table into a JSON-like text, which will be parsed by the server your sending it too into an Object or Array, therefore, b/c HookData.Content is set to LPlayer- which is a roblox Object,it might cause an issue.
if you want HookData.Content to be player's name then you'll have do player.Name, or call the built in function called tostring() which returns the name of the roblox object it's passed.
also, HttpService doesn't work in LocalScripts..it only works server side,and keep in mind you can't do game.Players.LocalPlayer in a server-sided script.
here is your code revised:
local Lplayer = game.Players.LocalPlayer
local url = ""
local http = game:GetService("HttpService")
local HookData = {
['username'] = "Builderman",
['content'] = Lplayer
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData)
18 comments
Will It work even if im in rbx studio?
if you APIEnabled to true from the Roblox website
also there's another bug, lemme edit my answer
So how do I turn it into a string?
you can call
tostring()with the object, which is equal to just doingObject.Name.. The __tostring meta function of objects returns the name of the object..Would I do like "local l = Lplayer:ToString" ?
Wait tostring() got deleted I think
roblox objects don't have a tostring() method. you need to call the global function called
tostring()which will extract the Name of the object passed to it..Please edit your answer :/
i will, hold one
So like "ToString(Lplayer") ?
ya, make sure there is no capital letters, lemme edit my answer
Ok
I got something but it just said nil
IM JUST GETTING NIL ON MY DISCORD SERVER!!!!!!!!!!!!!
^
there i just edited
Made it work