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

How can I make a model randomly generator somewhere on the map?

local iron = game.ReplicatedStorage.IronOre
local stone = game.ReplicatedStorage.StoneOre
local ores = 0
function RandomGen()
	while ores <= 20 do 
local newmodel = iron:Clone()
local newmodel2 = stone:Clone()
newmodel:MoveTo(Vector3.new(math.random(-247, 248), 2.52, math.random(-249, 249)))
ores = ores + 1
wait (.3)
	end
end

I am not very good with scripting but I'm trying to make it so that a ore will randomly spawn somewhere within the map.

1 answer

You didn't call the function, so your code will never run. RandomGen().

Also, you never give the iron a parent, so it will just be nil. newmodel.Parent = workspace

Other than that, it looks right, although of course you never use the stone.

6 comments

0

Is there a way I can make them not spawn on top of each other?

0

Yes. Instead of using MoveTo, use SetPrimaryPartCFrame. Because CFrame allows objects to clip eachother. Just make sure you have the PrimaryPart set.

0

I am not quite sure how to do that... Sorry for being a noob.

0

Just look up whatever you don't understand on the wiki, for example, http://wiki.roblox.com/index.php?title=API:Class/Model/SetPrimaryPartCFrame

0

That wiki page doesn't make any sense to me.

0

You can ask a question about specifically what you don't understand

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