Indirect tool holding? *Edited*
Goal Allow a player to hold a "Gun" without using a tool object, as i have toolbar disabled for my fps game.
ProblemThe code gives me this error: 11:24:49.896 - Players.Player.PlayerScripts.Loadout:10: attempt to call method 'clone' (a nil value)
Code
"Cloner"
01 | plr = game.Players.LocalPlayer |
04 | lo = game.ReplicatedStorage.Loadout |
07 | char:WaitForChild( "Humanoid" ) |
09 | gc = pmr:GetChildren() |
Welding
04 | RW, LW = Instance.new( "Weld" ), Instance.new( "Weld" ) |
06 | function WaitForChild(obj, ch_n) |
08 | while not obj:FindFirstChild(ch_n) and time() - t < 10 do wait( 0.1 ) end |
09 | return obj:FindFirstChild(ch_n) |
11 | script.Parent.Equipped:connect( function () |
12 | if selected then return end |
14 | player = game.Players:playerFromCharacter(script.Parent.Parent) |
15 | local ch = script.Parent.Parent |
16 | WaitForChild(ch, "Torso" ) |
17 | RSH = WaitForChild(ch.Torso, "Right Shoulder" ) |
18 | LSH = WaitForChild(ch.Torso, "Left Shoulder" ) |
19 | GRP = WaitForChild(ch [ "Right Arm" ] , "RightGrip" ) |
26 | RW.C 0 = CFrame.new( 1.5 , 0.5 , 0 ) |
27 | RW.C 1 = CFrame.new( 0 , 0.5 , 0 ) |
28 | RW.Part 1 = ch [ "Right Arm" ] |
33 | LW.C 0 = CFrame.new(- 1.5 , 0.5 , 0 ) |
34 | LW.C 1 = CFrame.new( 0 , 0.5 , 0 ) |
35 | LW.Part 1 = ch [ "Left Arm" ] |
42 | RW.C 0 = CFrame.new( 1.5 , 0.5 , 0.25 ) * CFrame.fromEulerAnglesXYZ( 1.3 *i, 0 , - 0.5 *i) |
43 | LW.C 0 = CFrame.new(- 1.5 , 0.5 , 0 ) * CFrame.fromEulerAnglesXYZ( 1.7 *i, 0 , 0.8 *i) |
44 | LW.C 1 = CFrame.new( 0.3 *i, 1 + 1 *i, 0 ) |
47 | local rg = (ch [ "Right Arm" ] :FindFirstChild( "RightGrip" ) or GRP) |
49 | GRP.Parent = ch [ "Right Arm" ] |
53 | script.Parent.Unequipped:connect( function () |
56 | RW.C 0 = CFrame.new( 0 , 0 , 0 ) * CFrame.fromEulerAnglesXYZ( 0 , 0 , 0 ) |
57 | LW.C 0 = CFrame.new( 0 , 0 , 0 ) * CFrame.fromEulerAnglesXYZ( 0 , 0 , 0 ) |
58 | LW.C 1 = CFrame.new( 0 , 0 , 0 ) |
61 | RSH.Part 1 = pl.Character [ "Right Arm" ] |
62 | LSH.Part 1 = pl.Character [ "Left Arm" ] |
67 | LW.C 0 = CFrame.new(- 1.5 , 0.5 , 0 ) * CFrame.fromEulerAnglesXYZ( 1.3 *i, 0 , 0.9 *i) |
68 | LW.C 1 = CFrame.new( 0.3 *i, 1 + 1 *i, 0 ) |
72 | for i = 0 , 0.3 , 0.06 do |
74 | GRP.C 0 = CFrame.new( 0 +i, - 1 -i, 0 +( 2 *i)) * CFrame.fromEulerAnglesXYZ(- 2.22 , - 0.45 , 0.42 ) |
75 | LW.C 0 = CFrame.new(- 1 , 0.5 , 0 ) * CFrame.fromEulerAnglesXYZ( 4.2 , 0 , 2.9 ) |
76 | LW.C 1 = CFrame.new( 0.8 *i, 1.1 +i, - 0.3 ) |
80 | RW.C 0 = CFrame.new( 1.5 , 0.5 , 0.25 ) * CFrame.fromEulerAnglesXYZ( 1.3 , 0 , - 0.5 ) |
81 | LW.C 0 = CFrame.new(- 1.5 , 0.5 , 0 ) * CFrame.fromEulerAnglesXYZ( 1.7 , 0 , 0.8 ) |
82 | LW.C 1 = CFrame.new( 0.3 , 1 + 1 , 0 ) |
83 | GRP.C 0 = CFrame.new( 0 , - 1 , - 0.5 ) * CFrame.fromEulerAnglesXYZ(- 1.22 , - 0.45 , 0.22 ) |