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

How can I clone an item from ServerStorage to a specific part in a model?

I'm trying to make a cannon that will fire projectiles stored in ServerStorage

Whenever I try to call out the item, instead of cloning a freestanding object where the barrel of the Cannon is, it simply merges the fireball with the Cannon model after spawning a cannonball in relative to it's last place on the Workspace before it was moved to ServerStorage.

I need it to be able to be spawned at the "Barrel" point of Model named Cannon to the point where I can apply a vector force and the likes.

local storage = game:GetService("ServerStorage")
local cBall = storage["cannonBall"]:Clone() 
cBall.Parent = game.Workspace.Cannon.Barrel

This is what I have so far, I can't go any further due to the part either not spawning in or it being merged into the Cannon model

Thanks in advance for any help

~MBacon15

1 answer

That should clone your part into the other object. However, you need to change the position of the part you cloned, here is an example for your script;

local storage = game:GetService("ServerStorage")
local cBall = storage["cannonBall"]:Clone() 
cBall.Parent = game.Workspace.Cannon.Barrel
cBall:MoveTo(game.Workspace.Cannon.Barrel.Position)

That uses the :MoveTo() function, you can use the position property, but MoveTo is much easier.

If you want to learn more about the MoveTo function, here is the wiki page:

http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo

If this helps, then click "Accept" answer, it gives us both rep!

3 comments

0

It returns this error 08:50:32.244 - MoveTo is not a valid member of Part 08:50:32.245 - Script 'ServerScriptService.Script', Line 3

0

Ahh, :MoveTo() Requires a Vector3 input, thanks. I'll go search around for declaring the position of the "Barrel" in a vector3 variable

0

Had to unaccept :| No matter what's done it keeps throwing out a "Not a valid member of part" error, and the function doesn't seem to want to even attempt to connect to ServerStorage

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