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

Whats wrong with my Model Cloning script?

Asked by
neoG457 315 Moderation Voter
9 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(key)
if key == "p" then

local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone() --Assuming the model is now in ReplicatedStorage
local primary_part = RinkakuModel.Primary -- Since this is used a lot, let's store it in a temporary variable
RinkakuModel.PrimaryPart = primary_part

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

primary_part.Anchored  = true -- Not sure if you still need to anchor it, if not you can leave it out.
for index = 1, 15 do
    local part = RinkakuModel["Part" .. index] -- This will generate Part1 till Part15
    local weld = Instance.new("Weld")
    weld.Part0 = primary_part
    weld.Part1 = part
    weld.C1 = part.CFrame:toObjectSpace(primary_part.CFrame)
    weld.Parent = primary_part
    part.Anchored = true -- Same here with the anchoring
    return weld
end


RinkakuModel:SetPrimaryPartCFrame(Player.Character.Torso.CFrame * CFrame.new(0, 10, 0))-- It's probably a good idea to use SetPrimaryPartCFrame before parenting it.
RinkakuModel.Parent = workspace

RinkakuModel:MakeJoints()-- You don't need to use MakeJoints because you did that manually
RinkakuModel.Name = Player.Name

end
end)


This script should clone WorkspaceRinkakuModel into workspace and weld the clone to my torso but its not working the output isnt saying anything is wrong with it. Please help this script is in a local script in starterpack

0
In line 26, why are you returning weld? Take that part out. DigitalVeer 1473 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

I don't know if this is the error, but the part :

if key == "p" then

Should change to:

if key:lower() == "p" then

I've had this error in one of my scripts before. It might be the error.

0
Or you could use if key == "p" or "P" then yoshiegg6 176 — 9y
Ad

Answer this question