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

Trying To Remove A Position From A Table So That The Part Wont Go To The Same Position?

Asked by 3 years ago
Edited 3 years ago

K So You Saw The Title I am Trying To Remove A Position From The Table So That The Part Wont Spawn On The Same Position Over And Over Again If There Is A Easy Solution To Do It Type It Down If Not Fix This Code

local Cap = 0
local Old = {}
local Points =
{
    Vector3.new(204.636, 173.826, 287.984),
    Vector3.new(140.636, 173.826, 202.984),
    Vector3.new(232.636, 173.826, 258.984),
    Vector3.new(203.636, 173.826, 258.984),
    Vector3.new(232.636, 173.826, 287.984)
}
local Coins = game.ReplicatedStorage.Coins10
local Time = 1

while true do
    if Cap < 4 then
        Cap = Cap + 1
        local CoinClone = Coins:Clone()
        CoinClone.Parent = game.Workspace.Coins
        local Position = Points[math.random(1,#Points)]
        CoinClone.Position = Position
        if CoinClone.Position == Vector3.new(0,0,0) then
            CoinClone:Destroy()
        end
        table.insert(Old,Position)
        table.remove(Points,Points[Position])
        wait()
        CoinClone.Pos.Value = CoinClone.Position
    else
        local Folder = game.Workspace.Coins:GetChildren()
        local RandomCoin = Folder[math.random(1,#Folder)]
        RandomCoin:Destroy()
        local Selected = Old[math.random(1,#Old)]
        table.remove(Old,Old[Selected])
        table.insert(Points,Old[Selected])
        Cap = Cap - 1
    end
    wait(Time)
end

Regards Steve

0
Any errors? Soban06 410 — 3y
0
nope kidsteve923 139 — 3y

Answer this question