Table printing full info in a table print but when i print its content in a loop it only prints the last output

so bassicly i was creating a script that loops trough a scrollingframe with textboxes then made a tables dictionary that gave the name of the textbox and the text then sends that table to the server and then loop trough it and set values based on the name and the text
it worked fine before but now it doesnt for some reason
when i print the normal table it works fine but when i print it in a loop with the same code i used before it doesnt anymore what could cause this problem?

local script

local plr = game.Players.LocalPlayer
local Character = plr.Character
local tool = plr.Backpack:GetChildren()[1]
local toolBackpack = plr.StarterGear:GetChildren()[1]
local Check = game.ReplicatedStorage.Values.IsPrivateServer.Value
local scripts = script.Parent.Parent.Scripts
local runservice = game:GetService('RunService')

script.Parent.MouseButton1Click:Connect(function()
	print("beforecheck")
	if Check or runservice:IsStudio() then
		print("check")
		local newtable = {}
		for i,v in pairs(scripts:GetChildren()) do
			if v:IsA("TextBox") then
				newtable[v.Name] = v.Text
				end
		end
		script.Parent.Click:FireServer(newtable)
	end
end)

server script

local function round(n)
	return math.floor(n + 0.5)
end






script.Parent.Click.OnServerEvent:Connect(function(plr,scripttable : {TextBox})
	local Character = plr.Character
	local tool = plr.Backpack:GetChildren()[1]
	local toolBackpack = plr.StarterGear:GetChildren()[1]
	for i,v in pairs(scripttable) do
		print(i,v)
		--if Character:WaitForChild("ScriptValues"):WaitForChild(i) then
			--Character:WaitForChild("ScriptValues"):WaitForChild(i).Value = v
		--end
	end
end)

i saw that someone tried to reply but then dindt send it :c i guess my new feature will never be implemented

yay finally people are replying

Use table built-in functions, like table.insert.
Remove {TextBox}, it’s most likely used to specify the dataType so it’s not needed.

Your indexes should be integers but you’re using strings(the textbox names), instead replace the following line:

newtable[v.Name] = v.Text

with:

table.insert(newtable, v.Text)

To make the keys numerical and the indexing proper.

If you want to keep using string keys, for starters, you should change the type checking of scripttable to {[string]: TextBox} instead of {TextBox}(Although this will only make code cleaner, not fix the issue).

Also, the issue might be caused by multiple text boxes having the same name, causing them to override each other within the table.

it dindt help removing the {textbox} it still just prints out

14:01:22.710 ▼ {
[“OnAbility”] = “”,
[“OnEquip”] = “”,
[“OnHit”] = “”,
[“OnUnEquip”] = “”,
[“WhenHitOnTarget”] = “”
} - Server - Script:14
14:01:22.711 WhenHitOnTarget

the first thing what it prints out is when i only print the scripttable like print(scripttable)

but when i print it in the loop it just pritns whenhitontarget

ugh i might just quit roblox studio
i suck at coding

but how come that it worked in the morning and all of a sudden it just breaks

thats it i quit this aint gonna work

It does work, there is no value that’s all.

take this as refrence:

local myTable = {
    sprintButton = "Hello"
}

myTable.jumpButton = "Jump"

-- myTable = {
--     sprintButton = "Hello",
--     jumpButton = "Jump"
-- }

print(myTable.sprintButton) -- Output: Hello
print(myTable.jumpButton)   -- Output: Jump

yes i know it prints whenhitontarget " " but the " " are invisible but it should just print all the lists values

i was about to quit but i tried in game for 1 last time and the tool still did work but not in studio, now just have to figure out the gui and atleast i did not give up however i still need allot of help

Where was WhenHitOnTarget comes from? Can you just ignore it?

from the table it goes trough all the childs with a name then it sets a string value

i tried it in game and it worked after i removed the is studio check kinda weird but better then it doesnt work at all

I am confused with the grammar

yes i am very young and english isnt my native language im ranging from 8 - 12 years old and my native language is dutch so sorry for the bad grammar

now a new issue formed, it only returns the first value in the table and sets it but all the others dont work

i fixed it myself, turned ouit i accidently removed a value that it was trying to set wich caused the loop to stop it works now thanks everyone for helping me!