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

How to Clone multiple models?

Asked by
VicyX 27
5 years ago

I have a simple script that will clone 2 Dice models (Dice1 and Dice2) to a Folder in the Workspace (GamePieces), then teleport them to a node and randomize their orientation.

The problem is that the script only clones 1 Die and doesnt even bother with the other. I put a print after the 2nd die to see if the script was getting past the 2 Die code and it was so its like the game is just ignoring the fact that i put the 2nd die code there

local WS = game:GetService("Workspace")
local RS = game:GetService("ReplicatedStorage")
local Dice1Node = WS.Nodes.DiceNode1
local Dice2Node = WS.Nodes.DiceNode2

local Dice1Clone = RS.GamePieces.Dice1:Clone()
Dice1Clone.Parent = WS.GamePieces
Dice1Clone:MoveTo(Vector3.new(Dice1Node.CFrame.X, Dice1Node.CFrame.Y - 5, Dice1Node.CFrame.Z))
Dice1Clone:SetPrimaryPartCFrame(Dice1Clone.PrimaryPart.CFrame * CFrame.Angles(math.rad(math.random(0,360)), math.rad(math.random(0,360)), math.rad(math.random(0,360))))

local Dice2Clone = RS.GamePieces.Dice2:Clone()
Dice1Clone.Parent = WS.GamePieces
Dice2Clone:MoveTo(Vector3.new(Dice2Node.CFrame.X, Dice2Node.CFrame.Y - 5, Dice2Node.CFrame.Z))
Dice2Clone:SetPrimaryPartCFrame(Dice2Clone.PrimaryPart.CFrame * CFrame.Angles(math.rad(math.random(0,360)), math.rad(math.random(0,360)), math.rad(math.random(0,360))))

1 answer

Log in to vote
1
Answered by
VicyX 27
5 years ago

I figured it out.....I was just stupid and didnt set the second die parent correctly...

Ad

Answer this question