Hey, I’m making a ban system that uploads to a database online.
The database rows go as follows:
id, UserID (ID of the person who has been banned), BanStart, BanTime, Reason, ModUserID
The ban is placed into the database via a URL and it says argument 2 is missing or nil. I have pasted the code down below.
game.ReplicatedStorage.Event.Event:Connect(function(player, uid, banstart, bantime, reason)
-- Please note that the following prints do print out argument 2
print(game.Players:GetUserIdFromNameAsync(player))
print(game.Players:GetUserIdFromNameAsync(uid))
print(banstart)
print(bantime)
print(reason)
local muid = game.Players:GetUserIdFromNameAsync(player)
local user = game.Players:GetUserIdFromNameAsync(uid)
local bs = os.time()
local bt = bantime
local r = reason
HttpService:PostAsync("https://[REDACTED]/create.php?ModUserID="..muid.."&UserID="..user.."&BanStart="..os.time().."&BanTime="..bt.."&Reason="..r.."")
game.Players[uid]:Kick(r)
end)
I’m so confused because when the print commands run, it prints out the expected argument. Anybody know why this is happening?
game.ReplicatedStorage.Event.Event:Connect(function(player, uid, banstart, bantime, reason)
-- Please note that the following prints do print out argument 2
print(game.Players:GetUserIdFromNameAsync(player))
print(game.Players:GetUserIdFromNameAsync(uid))
print(banstart)
print(bantime)
print(reason)
local muid = game.Players:GetUserIdFromNameAsync(player)
local user = game.Players:GetUserIdFromNameAsync(uid)
local bs = os.time()
local bt = bantime
local r = reason
HttpService:PostAsync("https://[REDACTED]/create.php?ModUserID="..muid.."&UserID="..user.."&BanStart="..os.time().."&BanTime="..bt.."&Reason="..r..,"")
game.Players[uid]:Kick(r)
end)```
HttpService:PostAsync requires atleast 2 arguments with the 2nd being the data you are actually sending.
You are only providing the 1st argument which is the url you are sending the data to.
Also I hope that you use your external server exclusivly for data logging as your approach isn’t secure in any shape or form.
Thank you, I know it’s not secure but I’m adding all security features to it after I’ve tested it to see if it works. Not my normal style of work but just testing it for now.
I got it to print out the link that it posted to, and copied and pasted it into Chrome, which added the record to the database, however, it does not add the record when I use PostAsync().
The php file grabs the data from the url using $_GET and adds it into the database. But Roblox sends the request and it says its been added, but it hasn’t. I’ll try different ways but not to worry if it doesn’t work.