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

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

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 = {Vector3.new(-59.5, 1.5, -23.5), Vector3.new(-59.5, 1.5, 26.5),Vector3.new(-8.23, 1.5, 26.467),Vector3.new(-8.5, 1.5, -23.5)}

function duplicatePiece()

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

local clonedPiece = OriginalPiece:Clone()

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

end


while true do

wait(10)
duplicatePiece()
end

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

2 comments

0

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)

0

I tried doing it, still does not work however. Thanks for . trying tho.

1 answer

✓ Accepted answer

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.

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