Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to remove someone from a table useing there name?

Asked by 9 years ago

Ok so iv been trying for hours this is all i could do D: please help!

function unminion(part)
    if part.Parent == p.Character then return end
            if part.Parent:FindFirstChild("Humanoid") ~= nil then
    v = part.Parent.Name
    for i,x in pairs(minions) do
        if (string.upper(v) == string.upper(x)) then
            table.remove(x,v)
        end
    end
end
end
0
What is the table here? BlueTaslem 18071 — 9y
0
This is just the function part the table is minions xXUltraAltraXx 20 — 9y
0
Instead of "v" on line 7, try "i", to index the "minions" table & remove that value. Redbullusa 1580 — 9y
0
No that didnt work D: xXUltraAltraXx 20 — 9y
1
Oops, the first parameter of the "remove" method for the "table" class should be a table value. So try "table.remove(minions, i). Redbullusa 1580 — 9y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

If you're going to remove something from minions, you would expect to see minions somewhere in the table.remove line.

Based on looking up what table.remove wants, it would be

table.remove(minions, i) -- as opposed to `v`

Tab your code correctly. Other cleanliness things might include using

            if v:upper() == x:upper() then

instead of

            if (string.upper(v) == string.upper(x)) then

Also remember to always use local variables; v isn't called local.

Ad

Answer this question