Hello,
Can someone help me and tell me how can i clone random model from ServerStorage with script. I only know how to clon 1 model, but i don’t know how can clone random model from this storage. Script:
local serv = game:GetService('ServerStorage')
local clon = serv:WaitForChild('clon')
local modelu = clon:WaitForChild('Model')
while true do
wait(1)
local model = modelu:Clone()
model.Parent = game.Workspace['3']
model:MoveTo(Vector3.new(-71.354, 3.732, -324.757))
wait(3)
model:Destroy()
end
local Children = ServerStorage:GetChildren() -- Gets an array table of all the children under serverstorage
local RandomIndex = math.random(1,#Children) -- Gets the number based on how many children there are
local RandomModel = Children[RandomIndex] -- Uses random number to retrive a value from array table
-- Add clone code
You might be aware of this but for those who aren’t the “1” argument to math.random() can be omitted, if math.random() is called with a single argument the lowest integer of the range of potential random numbers is always 1 by default.