Issue
Code gathers all the Tiles from a model, all of which contain a NumberValue
called Count and a BoolValue
called IsBomb. What i would like to know is how to get a certain number of Tiles from the table.
Code
repeat wait() until game:GetService("ContentProvider").RequestQueueSize <= 0 repStorage = game:GetService("ReplicatedStorage") if game.Players.LocalPlayer then local grid = repStorage.Grid local cGrid = grid:Clone() cGrid.Parent = workspace cGrid:MoveTo(Vector3.new(0, 0.5, 0)) for i, v in pairs(cGrid:GetChildren()) do if v:FindFirstChild('Count') then -- get 5 random tiles -- Set IsBomb to true within 5 tiles end end end
local children = cGrid:GetChildren() local tiles = {} for _,v in pairs(children) do if v:FindFirstChild("Count") and v:FindFirstChild("IsBomb") then table.insert(tiles,1,v) end end for i = 1,5 do local childNum = math.random(1,#tiles) local chosenTile = tiles[childNum] --do stuff with chosenTile table.remove(tiles,childNum) end