I want to clone a random meteor from the meteors folder inside the script, and put the clone in the workspace, but nothing happens!
I have tried parameters, like in this script:
local meteors = script.Meteors:GetChildren()
local randommeteor = math.random(1, #meteors)
local randomwait = math.random(1, 10)
local meteor = meteors[randommeteor]
function DropMeteor()
if meteors ~= nil then
while true do
meteor:Clone().Parent = workspace
wait(randomwait)
end
end
end
DropMeteor(meteor)
Please tell me if I have missed anything or did something wrong!
Oh, and forgot to mention, my script is in the ServerStorage service.
Your locals are set outside the function. Thus, whenever the script is first run, they will always be the same. Put them inside the function to make it choose another meteor every time.
You do meteor:Clone().Parent = workspace As far as I know this isn’t how you would do this. You could either do something like
local cloned = meteor:Clone()
cloned.Parent = workspace
or you could do
meteor:Clone(workspace)
If that doesn’t fix it, try putting print() through your function and see where it stops
Can you say where it is in the Explorer, though? Even if the code’s a bit messy, it should still run fine and spawn meteors. If nothing happens at all, the script probably isn’t running.