Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

error with my script It keeps saying string expected got nil)on line 34, can someone help?

Here is the script

local HttpService = game:GetService("HttpService")

local Webhook = {}
Webhook.__index = Webhook

function Webhook.new(name, team, timeAmount)
	return setmetatable({
		playerName = name,
		playerTeam = team,
		timeTaken = timeAmount,
	}, Webhook)
end

function Webhook:Post(webhook)
	local data = {
		embeds = {
			{
				title = "**ACTIVITY LOG**",
				color = 34749,
				footer = {
					text = "2"
				},
				fields = {
					{
						name = "**USERNAME**",
						value = 	string.upper(self.playerName)
					},
					{
						name = "**UNIT**",
						value = 	string.upper(self.playerTeam)
					},
					{
						name = "**TOTAL TIME**",
						value = 	string.upper(self.timeTaken)
					},
				}
			}
		}
	}

	data = HttpService:JSONEncode(data)
	HttpService:PostAsync(webhook, data)
end

return Webhook

1 answer

timeAmount may not be a string so you must convert it to a string.

Change line 10 to:

timeTaken = tostring(timeAmount),

if that does not work then try changing line 10 to:

timeTaken = tostring(timeAmount.Value),

If this solution works PLEASE mark this answer as accepted :)

This discussion is preserved as it was. New answers, comments, and votes are closed.