New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

Spawning a part in random positions gone wrong? (Updated)

Asked by 10 months ago
Edited 10 months ago

Basically, I am trying to spawn this part around a specific region on a map. I tried using Vector values to spawn the part but it still does not work. Instead of spawning in between that region, the piece only spawns on the positions. Help Is Appreciated and UpVoted! This is my following code:

local GrassIsCutted = false -- ignore this. its for a different purpose

local OriginalPiece = game.ServerStorage.OriginalPart

local positionsTable = {, 1.5, -23.5),, 1.5, 26.5),, 1.5, 26.467),, 1.5, -23.5)}

function duplicatePiece()

local position = positionsTable[math.random(1,#positionsTable)]

local clonedPiece = OriginalPiece:Clone()

clonedPiece.Position = position
clonedPiece.Parent = game.Workspace


while true do


I placed the OriginalPiece in the ServerStorage by the way. Thank you for taking your time to read and debug this. :)

Yeah so the script makes a copy of the piece and DOES position it; however, you do need to set its parent to something (For example: clonedPiece.Parent=game.Workspace) curtisornot 0 — 10mo
I tried doing it, still does not work however. Thanks for . trying tho. VVickedDev 39 — 10mo

1 answer

Log in to vote
Answered by 10 months ago

You forgot to set its parent to workspace; you won't see it in your game if you don't do this. So simply do

clonedPiece.Parent = workspace

right after you clone it and you should see it in your game.


Answer this question