Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a random part chooser and cloner?

What I am trying to do is have a script in the ServerScriptService choose a random part from a folder called "perks" in the ServerStorage that contains parts. I would like the script to choose a random part and clone it to the Workspace but everything I have tried so far has not worked. If possible, can anyone help me with this script?

1 answer

Try this:

folder = game.ServerStorage
function ClonePart()
    parts = folder:GetChildren() -- Get parts
    if #parts < 1 then return end -- Make sure parts are in the folder
    part = parts[math.random(1, #parts)]
    newpart = part:Clone()
    newpart.Parent = workspace
end
ClonePart() -- Use this to clone once
-- OR --
while wait(5) do ClonePart() end -- Clone every 5 seconds
    

This discussion is preserved as it was. New answers, comments, and votes are closed.