#How would I remove a string from a Dictionary inside another Dictionary
1 messages · Page 1 of 1 (latest)
Like ts
local Tuff = {}
Tuff.a = {"apple", "banana"}
Tuff.b = {"apple", "banana"}```
wym
local tuff = {
coolStuff = {
colour = "Red",
number = 5
}
}
do u mean like how to remove colour
no
table.remove(Tuff.a,1)
or you can use a loop
what if its not ordered and I don't know the order
for loop
like ts?
for i, v in pairs(tuff.a) do
if v == "apple" then
table.remove(v)
end
end```
or is that wrong
no wait lemme fix
for i, v in Tuff.a do
if v == "apple" then
table.remove(Tuff.a, i)
end
end
it says attempt it itterate over a string
are you sure
it work for me on studio
local Tuff = {}
Tuff.a = {"apple", "banana"}
Tuff.b = {"apple", "banana"}
for i, v in (Tuff.a) do
if v == "apple" then
table.remove(Tuff.a, i)
end
end
alright I'll send you my actual script
local Remote = game.ReplicatedStorage:WaitForChild("VoteRemote")
local Poll = {}
Poll.Single = {}
Poll.Double = {}
Remote.OnServerEvent:Connect(function(plr, Vote)
if Vote == "Single" then
Poll.Single = plr.Name
for i, v in Poll.Single do
if v == plr.Name then
table.remove(Poll.Single, i)
end
end
print(Poll)
elseif Vote == "Double" then
Poll.Double = plr.Name
for i, v in Poll.Single do
if v == plr.Name then
table.remove(Poll.Single, i)
end
end
print(Poll)
end
end)```
I don't think this is the most efficient way to do a poll but I'd want to do it myself
whats the exact error
ServerScriptService.Voting:18: attempt to iterate over a string value - Server -
its because your making Poll.Single a string
not an array that that the for loop can use