Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why random spawning system don't work?

Asked by 4 years ago

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

0
Is trash CanCollide = false iOwn_You 543 — 4y
0
Yup, can collide is set to false. ErktikyYT 89 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.

0
Still nothing. ErktikyYT 89 — 4y
0
You can change the position of something before Parenting. Memotag 226 — 4y
Ad
Log in to vote
0
Answered by
Memotag 226 Moderation Voter
4 years ago

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

Answer this question