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

How to set random spawn position for cloned parts?

I used math.random here but the cloned parts just keep spawning at the same place

local part = game.ReplicatedStorage.Part
local random = math.random(1,100)
while true do
	wait(5)
	local newPart = part:Clone()
	newPart.Parent = game.Workspace
	newPart.Position = Vector3.new(random,100,random)
end

It's my first time using math.random so please help me with it

2 answers

✓ Accepted answer

The issue here is that you are picking a random number once, and then you reuse it over and over in the while loop. You need declare random within the while loop if you want to select a new number for every iteration of the loop.

1 comment

0

Thanks for the answer!

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