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

My Cloning still isnt working?

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local debounce = false

Mouse.KeyDown:connect(function(key)
if key == "v" and not debounce then
debounce = true

game.ReplicatedStorage.WorkspaceRinkakuModel.PrimaryPart = ReplicatedStorage.WorkspaceRinkakuModel.Primary

local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone() 

 

Player = script.Parent.Parent

local   w = Instance.new('Weld')


w.Part0 = RinkakuModel.PrimaryPart
w.Part1 = Player.Character.Torso
w.Parent = RinkakuModel
w.C0 = CFrame.new(0, 0, 0)*CFrame.new(0, 0, 0)
RinkakuModel.Parent = workspace
RinkakuModel:MakeJoints()
RinkakuModel.Name = Player.Name

end
	end)

It should clone the model from Replicated Storage and weld the primary part to my torso when I press V But its not. This is a Local Script. Despite being called "WorkspaceRinkakuModel" the model is in Replicated Storage.

2 comments

0

Try Moving the Part to ServerStorage.

0

Serverstorage doesnt work with local scripts.

1 answer

After parenting it to the workspace, makejoints, and then parent the weld to the torso. That way the primary part isn't teleported before joints have been made.

Finished Script

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local m
m = Mouse.KeyDown:connect(function(key)
if key == "v" then
m:disconnect()
local RinkakuModel = game.ReplicatedStorage.RinkakuModel:Clone() --Assuming the model is now in ReplicatedStorage
local   w = Instance.new('Weld')
w.Part0 = RinkakuModel.PrimaryPart
w.Part1 = Player.Character.Torso
RinkakuModel.Parent = Player.Character
RinkakuModel:MakeJoints()
w.Parent = Player.Character.Torso
RinkakuModel.Name = Player.Name
end
end)

Comment if the code doesn't work for you, and I'll see what I might've done wrong.

4 comments

0

I tested the code, works fine.

0

Remember to use the command bar when setting the primary part. You don't have to use the primary part either. The part you want to be centered at the player's torso can be the primary part or can be used to take its place.

0

It definitely spawns however it spawns in the place where it was originally cut and pasted into Replicated Storage and not on my torso. Also my model is made of several parts that break because it isn't anchored. So how would I stop it from falling apart but be able to move with it welded to me at the same time?

0

Edited it and tried it with a full model. Assuming you have the proper surfaces on the model to keep the parts together, it will work.

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