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)
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.
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
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!