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

Why won't my gun appear when i try to weld it to my players arm?

-----------VARIABLES--------------
local player = game.Players.LocalPlayer --The player

local tool = script.Parent --The Hopperbin

local gun = game.Lighting.Flintlock --The gun itself

local ra = player.Character:WaitForChild('Right Arm') --Indentifies right arm for equip

local rl = player.Character:WaitForChild('Right Leg') --Infentifies right leg for unequip

---------MAIN SCRIPT----------------

tool.Selected:connect(function()
	gun:Clone(script.Parent)
	local w = Instance.new("Weld")
	w.Parent = tool:WaitForChild("Flintlock")	
	w.Part0 = ra
	w.Part1 = gun
	w.Part1.CFrame = CFrame.new(5,3,17)
end)

The gun doesn't appear in the players Right Arm like I want it to. What can I do to fix it?

1 comment

0

This is a local script, if FE is enabled. It will not be able to place the tool into Workspace. You will need a remote function somewhere in there.

1 answer

✓ Accepted answer

I can see a few problems with your script. On line 19, you have,

w.Part1 = 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.

-----------VARIABLES--------------
local player = game.Players.LocalPlayer --The player
local tool = script.Parent --The Hopperbin
local gun = game.Lighting.Flintlock:Clone()	 --The gun itself , cloned here for your convenience
local ra = player.Character:WaitForChild('Right Arm')	 --Indentifies right arm for equip
local rl = player.Character:WaitForChild('Right Leg') --Infentifies right leg for unequip

---------MAIN SCRIPT----------------

tool.Selected:connect(function()
    gun.Parent = tool --Places the gun into the tool
    local w = Instance.new("Weld")
    w.Parent = tool:WaitForChild("Flintlock")   
    w.Part0 = ra
    w.Part1 = gun -- Assuming the gun is a single part
    w.Part1.CFrame = CFrame.new(5,3,17)
end)

Let me know if this helped you!

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