You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am trying to create a host system, but I keep getting the HTTP 400 error when I try to send the passers to discord.
game.ReplicatedStorage.Session.OnClientEvent:Connect(function(Mode, Host)
local passers = function()
for _,v in pairs(game.Players:GetChildren()) do
if v.Status == "Passed" then
return true
else
return false
end
end
end
if Mode == "Start" then
script.Parent.Visible = true
script.Parent.Text = "Welcome to today's session! My name is "..tostring(Host)..", I will be your host for today."
wait(5)
script.Parent.Text = "I am assisted by my Co-Host."
wait(2.5)
script.Parent.Text = "I will now go over some rules for today's interview session."
wait(5)
script.Parent.Text = "1. Do not troll, caps abuse, or spam."
wait(2.5)
script.Parent.Text = "2. Always listen to you trainer, and the hosts."
wait(2.5)
script.Parent.Text = "3. Do not speak without requesting PTS, or being asked a question."
wait(5)
script.Parent.Text = "4. Do not try to disturb others, and do not cheat. We have chat logs to prevent this."
wait(5.5)
script.Parent.Text = "5. Always follow these rules. Failure to do so, will result in punishment."
wait(4.5)
script.Parent.Text = "We will now begin, please wait for an interviewer to call your name."
wait(4)
script.Parent.Visible = false
elseif Mode == "End" then
script.Parent.Visible = true
script.Parent.Text = "This interview session is now coming to an end."
wait(3.5)
script.Parent.Text = "Thank you for attending."
wait(2)
script.Parent.Text = "The failed people will now be kicked."
for _,v in pairs(game.Players:GetChildren()) do
if v.Status == "Failed" then
v:Kick("Sorry, but you have failed this session!\nPlease do not feel discouraged as you can always try again!")
end
end
wait(2.5)
script.Parent.Text = "Congrats! If you are seeing this message, that means that you passed!"
wait(5)
script.Parent.Text = "Please wait as I log the passers!"
game.ReplicatedStorage.SendtoDiscord:FireServer("Passers:\n"..tostring(passers()))
end
end)
Btw, after this is complete, it will be released to the public.
What exactly is “Status”? Is it a ValueObject?
This code is not complete - please as requested before add your Server code (however remove your webhook URL before you post it, or other people may be able to use it!)
Here is the server code. (The one that sends the webhook)
game.ReplicatedStorage.SendtoDiscord.OnServerEvent:Connect(function(content)
local http = game:GetService("HttpService")
local Data = {
["content"] = content
}
Data = http:JSONEncode(Data)
http:PostAsync("", Data)
end)
that’s not how I use it. and it doesn’t have to be like that.
I just need to know why whenever I add the arguments (the people who passed) it doest work.
But if I don’t add the people who passed, it works.
Because you return true or false in your passers function.
If you want to get a table of all people that passed you should do something like this:
local passers = function()
local passers = {}
for _,v in pairs(game.Players:GetChildren()) do
if v.Status == "Passed" then
table.insert(passers, v.Name)
end
end
return passers
end
And then when you fire the remote it should be something like:
Two issues I see, one… change OnServerEvent:Connect(function(content) to OnServerEvent:Connect(function(player,content)… the first value will always be the Player who sent the request value.
Next, add wait(0.05) above local http = game:GetService("HttpService"). This prevents the HTTPs Request from being overly spent, just a tip I learned a little while ago.
Third, there needs to be a link for the webhook to post somewhere. So, may a value called local WebhookURL = "WebhookLinkHere".
After that, change http:PostAsync("", Data) to http:PostAsync(WebhookURL, Data)
Tell me what the results are after testing please.