How would I clone a part into workspace from server storage?

So, I’m trying to make it so that I spawn in a group of parts that have body velocity from server storage. image

I’m trying to make that group of parts to clone into workspace. And then have them despawn after 5 seconds.

2 Likes
 game.ServerStorage.Parent = game.Workspace
 —Put a value in replicatedstorage
    Game.ReplicatedStorage.Value = 2
  Game.ServerStorage.Value = game.Workspace

Tell me what the error is if there is one

1 Like

What do you mean by “Put a value in”

1 Like

the value is the part clone. The value has to be the number of the parts you want.

1 Like

So basically you want to clone a group of parts into workspace and despawn them after 5 seconds? Sure!

local BoneSpawn = game.ServerStorage.BoneSpawn:Clone()

BoneSpawn.Parent = workspace 

wait(5)


BoneSpawn:Destroy()

Also, could you be specific about the BodyVelocity, what would you do with it?

2 Likes

Why are you setting the parent of the ServerStorage to the workspace and why are you setting a value to a workspace?

2 Likes

So, I have a undertale themed “Obby” and at times the enemy will shoot out the group of parts (bones) And the body velocity would make them goto the player. And the player would have to jump over them.

1 Like

You can’t clone from the client and if your replicating form a service that hasn’t been rendered yet and you wanna put it in a service still that doesn’t get render’d such as starter pack you need to clone it to workspace then clone it to starter pack

1 Like

Do you know how I could make it so the whole group is effected by the body velocity?

1 Like

Oh right! Well, since the BodyVelocity will work with it’s parent, maybe you could create a part which can be the primary part of the group and set the parent of the BodyVelocity to the primary part.

So basically:

  • Create a part and put it into the group
  • Set the model’s/group’s primary part to the part you created
  • Create a BodyVelocity and parent it to the part that you just created which means that when the primary part moves, then the whole model will too.

What do you mean by primary part?

Read here if you really don’t know what it is.

I should watch a youtube video, I don’t understand that at all.

So, I tried this but it doesn’t seem to work, can you help debug it?

workspace.BoneSpawn.PrimaryPart = workspace.BoneSpawn.Center

while true do
	for i = 1,100 do 
		wait()
		
		workspace.BoneSpawn.SetPrimaryPartCFrame(CFrame.new(workspace.BoneSpawn.PrimaryPart.Position + Vector3.new(0,0,1)))
	end
end

Oh so let me explain it here:

A primarypart is basically a part that is mostly in control of the model, so for example a player’s character primary part is a HumanoidRootPart, when that HumanoidRootPart moves then the rest of the character will, so from that definition, I would want you to create a part and put it into the model so that it can control the primarypart which will control the model, if you still don’t get what I mean then feel free to watch a YouTube video.

Add a wait() on the while loop not on the for loop:

I tried for it to be anchored and unanchored but it still doesn’t work…

Oh I missed out something, do :SetPrimaryPartCFrame not .SetPrimaryPartCFrame because it’s a function, so swap the period to the colon.

try this
Server script

local BoneSpawn = game.ServerStorage:WaitForChild("BoneSpawn"):Clone()

BoneSpawn.Parent = workspace

local Waiting = os.time()

repeat wait() 
if os.time() - Waiting <5 then
if workspace:FindFirstChild("BoneSpawn") then
workspace.BoneSpawn:Destroy()
break
end
else
continue
until os.time()-Waiting < 5

I hope that works

The spawning script is working but the moving script is not, This is the moving script that I have. I also currently have the moving script in workspace.

workspace.BoneSpawn.PrimaryPart = workspace.BoneSpawn.Center

while true do
	for i = 1,100 do 
		
		
		workspace.BoneSpawn:SetPrimaryPartCFrame(CFrame.new(workspace.BoneSpawn.PrimaryPart.Position + Vector3.new(0,0,1)))
	end
      wait() -- add a wait to the while loop so it does not crash the game 
end