Loops not runnign on server script

I am back again, anyways.

I have this loop:

local Rest
		for i ,v in ipairs(Answer) do
			if Rest == "" then
			Rest = ('{	["name"] = "'..v..'",	["value"] = "["..player.Name.."](https://roblox.com/users/"..player.UserId.."/profile)",	["inline"] = true },')
			else
				Rest= Rest..("")	
			end		
		end

The thing is that the loop is not running but the rest of the code in the script does, which means it send to the discord webhook but simply does not adds the values. I tried printing i,v apart to see what happens but simply bypass it. Anyone can help me making the loop work?

There’s pretty vague references here, have you tried checking to see if the “Answer” table is not empty?

The “Answers” table is being passed by a remote event. The table gets filled with information from the client. As shown below:

for i, Element in ipairs(Children) do 
			if Element:IsA("ImageLabel") then
				if Element.Answer.Text ~= "" then
					print("txt"..Element.Name)
					AnswerQuery[string.sub(Element.Name, 9)]	= Element.Answer.Text
					
				else
				warn(Element.Name)
				Submit.Text = "MISSING ANSWER(S)"
				wait(5)
				Submit.Text ="APPLY"
				return
			end
			end
	end

Where AnswerQuery is the same Answer

Paste your remoteevent script, dont forget remoteevents dont return any data, they can only pass information through arguments

By the script you mean the server-side one or the client.side one?

paste the OnServerEvent function and the OnClientEvent function

Client:

--//Credits to iSt_xrm\\--


script.Parent.Submit.Activated:Connect(function()
--//Varibales\\--
local Event = game.ReplicatedStorage.Webhook
local Submit = script.Parent.Submit
local Children = script.Parent.Frame:GetChildren()
local plr = game.Players.LocalPlayer
local AnswerQuery = {}
	
	table.sort(Children, function(a, b)
   	 return string.lower(a.Name) < string.lower(b.Name) 
	end)
	
	for i, Element in ipairs(Children) do 
			if Element:IsA("ImageLabel") then
				if Element.Answer.Text ~= "" then
					print("txt"..Element.Name)
					AnswerQuery[string.sub(Element.Name, 9)]	= Element.Answer.Text
					
				else
				warn(Element.Name)
				Submit.Text = "MISSING ANSWER(S)"
				wait(5)
				Submit.Text ="APPLY"
				return
			end
			end
	end

	Event:FireServer(AnswerQuery)

	script.Parent.Parent.Questions.Visible = false
	script.Parent.Parent.Sending.Visible = true
----
end)

Server:

--//Creidts to iSt_xrm\\--
--//Do not delete credits please. If you require further assistance make sure to contant ME only me through Discord. iSt_xrm#7250\\--


--//Varibales\\--
local EVENT = game.ReplicatedStorage.Webhook


EVENT.OnServerEvent:Connect(function(player, Answer)
		
		
		
		--//Varibales\\--
		local Http = game:GetService("HttpService")
		local webHook = require(script.WebhookAPI)
		local PlaceName = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name
		local IMG = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username="..player.Name
		local Title
		local WebhookId
		local WebhookToken
		
		
		local Rest
		for i ,v in ipairs(Answer) do
			if Rest == "" then
			Rest = ('{	["name"] = "'..v..'",	["value"] = "["..player.Name.."](https://roblox.com/users/"..player.UserId.."/profile)",	["inline"] = true },')
			else
				Rest= Rest..("")	
			end		
		end


		
			local Discord_Webhook = webHook.new(WebhookId,WebhookToken) 
			Discord_Webhook:post{
				username = Title,
				["embeds"] = {{
			["title"] = "**Applications | By iSt_xrm**",
			["type"] = "rich",
			["color"] = tonumber(0xb51b20),
			["thumbnail"] = {["url"] = IMG},
			["footer"] = {
				["text"] = "System by iSt_xrm",
				["icon_url"] = "https://cdn.discordapp.com/attachments/636740004890017792/636748580639735828/256-256-5fbc60a4335d01cd9c35dcf8fae02410.png"},
			["fields"] = {
				{
					["name"] = "Applicant :person_with_blond_hair:",
					["value"] = "["..player.Name.."](https://roblox.com/users/"..player.UserId.."/profile)",
					["inline"] = true
				},
				{
					["name"] = "Applicant Rank :medal:",
					["value"] = player:GetRoleInGroup(5121069),
					["inline"] = true
				},
				Rest
				
			}
		}}		
			}
		
		
end)

Itself I made it before so the for i,v print, but it dont prints so I tried this and neither. (Server script)

did a quick read and this looks fine, the “error” must be coming from the client where the “AnswerQuery” must have no values in it. Before this line:

Event:FireServer(AnswerQuery)

add this:

for i, v in next, AnswerQuery do
print(i,v)
end

I just did other thing. So no mroe needed.

Does that mean you solved it? If so, post what you did to solve it and mark it as solved.

Yes, it means that I solved it.

Cool what did you do to solve it?

Post it here for others if they every have that issue.

Then mark it as solved so others don’t come here and start writing for ages trying to help.

I just turned all into a string and added the “…” simple.

1 Like