01 | -----------VARIABLES-------------- |
02 | local player = game.Players.LocalPlayer --The player |
03 |
04 | local tool = script.Parent --The Hopperbin |
05 |
06 | local gun = game.Lighting.Flintlock --The gun itself |
07 |
08 | local ra = player.Character:WaitForChild( 'Right Arm' ) --Indentifies right arm for equip |
09 |
10 | local rl = player.Character:WaitForChild( 'Right Leg' ) --Infentifies right leg for unequip |
11 |
12 | ---------MAIN SCRIPT---------------- |
13 |
14 | tool.Selected:connect( function () |
15 | gun:Clone(script.Parent) |
The gun doesn't appear in the players Right Arm like I want it to. What can I do to fix it?
I can see a few problems with your script. On line 19, you have,
1 | w.Part 1 = gun |
That line is attempting to set the entire model as part1. Unless the flintlock is a single part. Also, you didn't move the gun into the tool, therefore the clone is still in the lighting. Below is a code that should work.
01 | -----------VARIABLES-------------- |
02 | local player = game.Players.LocalPlayer --The player |
03 | local tool = script.Parent --The Hopperbin |
04 | local gun = game.Lighting.Flintlock:Clone() --The gun itself , cloned here for your convenience |
05 | local ra = player.Character:WaitForChild( 'Right Arm' ) --Indentifies right arm for equip |
06 | local rl = player.Character:WaitForChild( 'Right Leg' ) --Infentifies right leg for unequip |
07 |
08 | ---------MAIN SCRIPT---------------- |
09 |
10 | tool.Selected:connect( function () |
11 | gun.Parent = tool --Places the gun into the tool |
12 | local w = Instance.new( "Weld" ) |
13 | w.Parent = tool:WaitForChild( "Flintlock" ) |
14 | w.Part 0 = ra |
15 | w.Part 1 = gun -- Assuming the gun is a single part |
16 | w.Part 1. CFrame = CFrame.new( 5 , 3 , 17 ) |
17 | end ) |
Let me know if this helped you!