I'm trying to issue a post request via RemoteFunction, but the in pairs() loop is not working.
I'm getting an error trying to tell me im using the incorrect datatype for the 'pairs', but the argument is a table.
Server script:
local http = game:GetService('HttpService')
local database = 'http://boomlings.com/database/'
game.ReplicatedStorage:WaitForChild('IssuePostRequest').OnServerInvoke = function(php, param)
local data = ''
for i, v in pairs(param) do
data = data .. ('&%s=%s'):format(
http:UrlEncode(i),
http:UrlEncode(v)
)
end
data = data:sub(2)
print(data)
local returned
local success, eMes = pcall(function()
returned = http:PostAsync(database..php, data, Enum.HttpContentType.ApplicationUrlEncoded, false)
end)
if success then
return {'Success', returned}
else
return {'Error', eMes}
end
end
Local script:
local CAS = game:GetService('ContextActionService')
local secretC = 'Wmfd2893bg7'
CAS:BindAction('Response', function()
local response = game.ReplicatedStorage:WaitForChild('IssuePostRequest'):InvokeServer('getGJUserInfo20.php', {
secret = secretC,
targetAccountID = 7362432
})
if response[1] == 'Success' then
print(response[2][3])
else
warn(response[2])
end
end, false, 'e')
You are free to correct my Http code, because I am extremely new to it.

1 comment
Can't believe i forgot that. Thank you!