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

save something from a table?

Asked by
Elixcore 1337 Moderation Voter
5 years ago
Edited 5 years ago

so let's say i want to move something from my table (temporarily) and put it back in later, how would I do it?

ways that are not permitted in this instance: making another table, removing it from the first and adding it to the second keeping its position the same.

local rndm = math.random(1, #spawns)
        model.PrimaryPart.CFrame = spawns[rndm]
        table.insert(usedspawns, rndm, spawns[rndm])
        table.remove(spawns, rndm)
        model.Name = kind
        model.Humanoid.Died:Connect(function()
            table.insert(spawns, rndm, usedspawns[rndm])
            table.remove(usedspawns, rndm)
            model:Destroy()
            wait(5)
            createchar(kind)
        end)

script above is part of a function that generates a randomly created character, including a randomized spawn location placed inside a table, the current method is not good because it will error saying "CFrame expected, found nil" because math.random searches from 1 to the last number of the array, meanwhile the array has missing numbers like 5,6 etc.

0
removing it and adding it back would be the best option right now. User#19524 175 — 5y
0
that's why im having trouble, I can't do that. Elixcore 1337 — 5y

Answer this question