--to use: put in type of gun: barrel point left, barrel point right or bull-pup(main hande is in the middle of the gun)


                                  --step 2: put in what type of wepoan it is: assult rifle or pistol(there will be more)
guntype = 1               --1 is assult rifle, 2 is bullpup, 3 is pistol, 4 is knife
weldmode = 1            --1 is barrel point upper-left, 2 is barrel pointing upper-right, 3 is barrel point lower-left and 4 is barrel point lower-right
                                  -------(note: if it is pistol or knife then 1 is on right leg, 2 is on left leg, 3 is in the back of your pants and 4 is in the front of your pants)
model = nil                 --gun model, that is
distance = 0.75          --this is the distance between the part(torso/leg) and the gun. DON'T MAKE negitive
rotation = 135              --this is the turning in degrees.
                                   --this area is mode more for someone who's already good at gun's. please do not get mad at me if you don't understand what's under here
y = 2                           --this is what's added to the current y value. positive number's make it go down. negative make's it go up
 x = -.75                          --this is what's added to the x value(it's really the z value but it look's like the x value when on your back). positive number's make it go left. negative make's it go right

parts = {}
local n = 1

function on(mouse)
if model == nil then
n = 1
local m = Instance.new("Model")
local all = script.Parent:GetChildren()
for i = 1, #all do
if all[i].className == "Part" then
parts[n] = all[i].Transparency
local brick = all[i]:clone()
brick.Parent = m
n = n +1
end
end
wait()
if model == nil then
local weld = script:FindFirstChild("Weld2")
if weld ~= nil then
local new = weld:clone()
new.Disabled = false
new.Parent = m
m.Name = script.Parent.Name
m.Parent = script.Parent.Parent
model = m
local handle = model:FindFirstChild("Handle")
if handle ~= nil then


if guntype == 1 then
local torso = model.Parent:FindFirstChild("Torso")
if torso ~= nil then
if weldmode == 1 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2), 0)
elseif weldmode == 2 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2 ) *-1, 0)
elseif weldmode == 3 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, -0.1+y, 0.2 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2), -1.5)
elseif weldmode == 4 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0.25+y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2 +rotation) *-1.1, 1)
end
end




elseif guntype == 2 then
local torso = model.Parent:FindFirstChild("Torso")
if torso ~= nil then
if weldmode == 1 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0.25+y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2, 0)
elseif weldmode == 2 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2 *-1, 0)
elseif weldmode == 3 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2, 0)
elseif weldmode == 4 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2 *-1, 0)
end
end




elseif guntype == 3 then
local lleg = model.Parent:FindFirstChild("Left Leg")
local rleg = model.Parent:FindFirstChild("Right Leg")
if lleg ~= nil and rleg ~= nil then
if weldmode == 1 then
local w = Instance.new("Weld")
w.Part0 = rleg
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
elseif weldmode == 2 then
local w = Instance.new("Weld")
w.Part0 = lleg
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
elseif weldmode == 3 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2, 0)
elseif weldmode == 4 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2 *-1, 0)
end
end




elseif guntype == 4 then
local lleg = model.Parent:FindFirstChild("Left Leg")
local rleg = model.Parent:FindFirstChild("Right Leg")
local torso = model.Parent:FindFirstChild("Torso")
if lleg ~= nil and rleg ~= nil and torso ~= nil then
if weldmode == 1 then
local w = Instance.new("Weld")
w.Part0 = rleg
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0)
elseif weldmode == 2 then
local w = Instance.new("Weld")
w.Part0 = lleg
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0)
elseif weldmode == 3 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2, 0)
elseif weldmode == 4 then
local w = Instance.new("Weld")
w.Part0 = torso
w.Parent = w.Part0
w.Part1 = handle
w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2 *-1, 0)
end
end
end
end
end
end
end




if model ~= nil then
n = 1
local all = model:GetChildren()
for i = 1, #all do
if all[i].className == "Part" then
all[i].Transparency = 1
end
end
end
end

function off(mouse)
if model ~= nil then
n = 1
local all = model:GetChildren()
for i = 1, #all do
if all[i].className == "Part" then
all[i].Transparency = parts[n]
local Do = true
if Do then
Do = false
n = n +1
end
end
end
end
end

script.Parent.Equipped:connect(on)
script.Parent.Unequipped:connect(off)