I have a boat model inside workspace
with children inside it. I was wondering if I could clone it in a function with an instance and then move where it is on the Axis of the world, but i am grappling with the fact of the matter. If i were to do the script it would be something like
function begingame() newboat = Instance.new("BoatModelName") newboat.Position = X,Y,Z end begingame()
if anyone knows a way to do this, find a way around it, or do it in a different "way", then help me please. Thankyou for your time.
Instances in ROBLOX have a clone
method which will create a copy of the instance and give you the new reference.
First, you would need to set a reference to your model that you want to clone. If, for example, your model you want to clone is "Boat" and is placed directly into workspace, you can reference it like so:
local boat = workspace:WaitForChild("Boat")
Now that we have stored the model into the variable boat
, we can clone the instance into another variable.
local boatClone = boat:Clone()
At this point, you may freely manipulate boatClone
! If you want to change the position:
-- Sets the position of the cloned boat to X=0, Y=0, Z=0. boatClone.position = Vector3.new(0, 0, 0)
This is what the compiled script might look like:
-- Get the reference to the boat instance local boat = workspace:WaitForChild("Boat") -- An example of a function that will clone the boat and move it to a specified position local function spawnNewBoatAtPos(x, y, z) local boatClone = boat:Clone() boatClone.position = Vector3.new(x, y, z) end -- A sample call to the function at X=13, Y=2, Z=10 spawnNewBoatAtPos(13, 2, 10)
Hope this helps! :)