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

My Cloning still isnt working?

Asked by
neoG457 315 Moderation Voter
9 years ago
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.

0
Try Moving the Part to ServerStorage. woodengop 1134 — 9y
0
Serverstorage doesnt work with local scripts. neoG457 315 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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.

0
I tested the code, works fine. aquathorn321 858 — 9y
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. aquathorn321 858 — 9y
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? neoG457 315 — 9y
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. aquathorn321 858 — 9y
Ad

Answer this question