I'm getting an error that I cannot diagnose for some reason. I'm trying to use HTTPService with Discord to send a message to a server, and I'm trying to convert it into a require(). But this error keeps on popping up!
On server: Model.MainModule:3: invalid argument #4 (string expected, got table) Stack Begin Script 'Model.MainModule', Line 3 - function Start Script 'ServerScriptService.Webhook', Line 4 Stack End
Here are the scripts:
(the Require script, in ServerScriptService)
local joinwebhook = "(censored)"
local clogwebhook = "(censored)"
require(CensoredMainModule):Start(joinwebhook, clogwebhook)
(the ModuleScript)
local module = {}
function module.Start(joinhook, cloghook)
script.WebhookConfig.JoinsHook.Value = joinhook
script.WebhookConfig.ChatLogHook.Value = cloghook
script.WebhookConfig.Parent = game.ServerScriptService
script["Chat Logs"].Parent = game.ServerScriptService
script.Joins.Parent = game.ServerScriptService
end
return module
(the Joins Script in the ModuleScript)
local webhook = script.Parent.WebhookConfig.JoinsHook.Value
local HTTPService = game.HttpService
local PlaceInfo = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
game.Players.PlayerAdded:Connect(function(plr)
local stuff = HTTPService:JSONEncode({
content = plr.Name .. " joined " .. PlaceInfo.Name,
username = plr.Name .. " - " .. plr.UserId
})
HTTPService:PostAsync(webhook, stuff)
end)
(the Chat Logs Script in the ModuleScript)
local webhook = script.Parent.WebhookConfig.ChatLogHook.Value
local HTTPService = game.HttpService
local PlaceInfo = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(message, recipient)
local stuff = HTTPService:JSONEncode({
content = message,
username = plr.Name .. " at place " .. PlaceInfo.Name
})
HTTPService:PostAsync(webhook, stuff)
end)
end)
Here is the WebhookConfig folder: MainModule ->WebhookConfig --->ChatLogHook (stringvalue) --->JoinHook (stringvalue)
