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

Help me with my cloning please?

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()
		Mouse.KeyDown:connect(function(key)
		
	
	if key == "v" then 
		
		Player = script.Parent.Parent
		
		game.Workspace.WorkspaceRinkakuModel:MakeJoints()
		
		local WRM = game.workspace.WorkspaceRinkakuModel
		
		local RinkakuModel = WRM:Clone()
		
		RinkakuModel.Parent = workspace
		RinkakuModel.Name = Player.Name

local	w = Instance.new('Weld')
		w.Part0 = RinkakuModel
		w.Part1 = Player.Character.Torso
		w.Parent = RinkakuModel
		w.C0 = CFrame.new(0, 0, 0)*CFrame.new(0, 0, 0)
	
	
	
	
	
	end
		end)
			
				
			

This script should make a clone of WorkspaceRinkakuModel (Which Is In Workspace, Of Course) and weld it to my torso whenever I press V. But it doesnt seem to work and I dont know whats wrong with it, there are no visible errors and the script is a localscript in starterpack. Help please?

1 comment

0

Change WorkspaceRinkakuModel's CFrame to the torso's Position.

1 answer

There are a couple of evident problems. First off, you use makejoints on the initial model whenever you press v instead of the clone. Makejoints should be called on the clone after creating the weld. You should also use debounce so that you can't repeatedly clone your model. It's probably also a good idea to parent the clone to the character instead of workspace, and you should consider putting the model to clone inside of ReplicatedStorage.

Finished Script

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
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
w.Parent = RinkakuModel
w.C0 = CFrame.new(0, 0, 0)*CFrame.new(0, 0, 0)
RinkakuModel.Parent = Player.Character
RinkakuModel:MakeJoints()
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.

2 comments

0

Sorry, but its still not working. The model is in replicatedstorage

0

I see you're problem. You're welding the model to the torso. I'll have to edit it later, I've gotta go somewhere. Try setting Part0 to the primary part of the model.

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