This script of the pistol broke, so basically the weld of this pistol is broken and it does not shoot.
It broke because of ROBLOX updates but I don't know how to fix it.
Can any of you help? Thank you!
Here it is:
local pellet = Instance.new("Part")
pellet.Name = "Bullet"
pellet.Shape = 0
--pellet.Transparency = 0.3
pellet.BrickColor = BrickColor.new("Bright yellow")
pellet.Size = Vector3.new(1,1,1)
pellet.CanCollide = false
local reloadSound = Instance.new("Sound")
reloadSound.SoundId = "http://www.roblox.com/asset/?id=2920960"
reloadSound.Parent = script.Parent
reloadSound.Volume = .5
local fireSound = Instance.new("Sound")
fireSound.SoundId = "http://www.roblox.com/asset/?id=2760979"
fireSound.Parent = script.Parent
fireSound.Volume = .5
--player
player = nil
--save shoulders
RSH, LSH = nil, nil
--grip
GRP = nil
--welds
RW, LW = Instance.new("Weld"), Instance.new("Weld")
--what anim
anim = "none"
--onselected, save shoulders and get player
script.Parent.Equipped:connect(function()
script.Parent.Name = "["..script.Parent.Ammo.Value.."]["..script.Parent.Clips.Value.."]"
player = game.Players:playerFromCharacter(script.Parent.Parent)
local ch = script.Parent.Parent
RSH = ch.Torso["Right Shoulder"]
LSH = ch.Torso["Left Shoulder"]
GRP = ch["Right Arm"].RightGrip
--
RSH.Parent = nil
LSH.Parent = nil
--
RW.Part0 = ch.Torso
RW.C0 = CFrame.new(1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
RW.C1 = CFrame.new(0, 0.5, 0)
RW.Part1 = ch["Right Arm"]
RW.Parent = ch.Torso
_G.R = RW
--
LW.Part0 = ch.Torso
LW.C0 = CFrame.new(-1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
LW.C1 = CFrame.new(0, 0.5, 0)
LW.Part1 = ch["Left Arm"]
LW.Parent = ch.Torso
_G.L = LW
--
GRP.C0 = CFrame.new(-0.25, -1, -0.2) * CFrame.fromEulerAnglesXYZ(-1.577, -0.6, 0)
--Bring_Arm_Up animation
for i = 0, 1, 0.05 do
wait()
RW.C0 = CFrame.new(1, 0.5, -0.5) * CFrame.fromEulerAnglesXYZ(1.62, 0, -0.6)
LW.C0 = CFrame.new(-1, 0.5, -0.5) * CFrame.fromEulerAnglesXYZ(1.62, 0, 0.6)
--LW.C1 = CFrame.new(-0.3i, 0.5+1.2i, 0)
end
end)
script.Parent.Unequipped:connect(function()
script.Parent.Name = "Pistol"
--Bring_Arm_Down animation
RSH.Parent = player.Character.Torso
LSH.Parent = player.Character.Torso
RW.Parent = nil
LW.Parent = nil
end)
function Reload()
if (script.Parent.Clips.Value~=0) and (script.Parent.Ammo.Value<=7) then
--start homerunhit connection--
--local con = script.Parent.Handle.Touched:connect(HomeRunHit)
--[[for i = 0, 1, 0.2 do
wait()
LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.62, 0, 0.8+0.6*i)
end]]
wait(0.5)
script.Parent.Ammo.Value = 8
script.Parent.Clips.Value =script.Parent.Clips.Value - 1
reloadSound:play()
end
end
function Fire()
if (script.Parent.Ammo.Value~=0) then
fireSound:play()
script.Parent.Ammo.Value =script.Parent.Ammo.Value - 1
local b = pellet:Clone()
b.Parent = workspace
local target = script.Parent.Parent.Humanoid.TargetPoint - script.Parent.Handle.Position
local dir = computeDirection(target)
local pos = script.Parent.Handle.Position + (dir * 5)
local bcframe = CFrame.new(pos, pos + dir)
local foirc = bcframe * CFrame.fromEulerAnglesXYZ(math.random(0,50) / 3000, math.random(-50,50) / 3000,0)
b.CFrame = foirc
local bv = Instance.new("BodyVelocity")
bv.maxForce = Vector3.new(1e+009,1e+009,1e+009)
bv.velocity = foirc.lookVector * 150
bv.Parent = b
local s = script.Parent.BulletHit:clone()
s.Disabled = false
s.Parent = b
end
end
function computeDirection(pos)
local invrtDir = 1 / math.sqrt((pos.magnitude * pos.magnitude))
local dir = Vector3.new(pos.x * invrtDir, pos.y * invrtDir, pos.z * invrtDir)
return dir
end
local lastclick = false
script.Parent.MouseClick.Changed:connect(function()
if (lastclick == false) then
lastclick = true
anim = "norm"
last_click = time()
Fire()
wait(0.1)
lastclick = false
end
end)
local lastkey = false
script.Parent.KeyClick.Changed:connect(function()
if (lastkey == false) then
lastkey = true
anim = "reload"
last_click = time()
Reload()
wait(0.5)
lastkey = false
end
end)
script.Parent.Ammo.Changed:connect(function()
script.Parent.Name = "["..script.Parent.Ammo.Value.."]["..script.Parent.Clips.Value.."]"
end)
script.Parent.Clips.Changed:connect(function()
script.Parent.Name = "["..script.Parent.Ammo.Value.."]["..script.Parent.Clips.Value.."]"
end)