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

Why random spawning system don't work?

Hello, devs!

I was making trash system to a game. Don't know why it's not working. There are no errors on output. In script I was cloning Union and then changing position. Maybe union was the problem, but I don't know. Script is located in the model which has a part that size properties was used.

CODE:

while wait(math.random(1,3)) do
	local pos1 = math.random(-12,12)
	local pos2 = math.random(-12,12)
	
	local trash = game.ReplicatedStorage.Trash:Clone()
	trash.Position = Vector3.new(pos1, 10, pos2)
	trash.Anchored = false
	trash.Parent = game.Workspace
end

ERRORS:

No erorrs

2 comments

0

Is trash CanCollide = false

0

Yup, can collide is set to false.

2 answers

Not completely sure about the answer, But I think you can't change the Position before the parent is the workspace, try to put the part in the workspace, and then change the position.

2 comments

0

Still nothing.

0

You can change the position of something before Parenting.

Your code seems to be working perfectly on my end. Make sure that your parts aren't falling below the map and getting destroyed.

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