this script probably looks really inefficient but, I'm making a throwing script and it says I have an error on line 39 which is mouse.Button1Down:connect(function()
local carrying
local welds = {}
local arms = nil
local torso = nil
local p = script.Parent
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local char = plr.Character
local mouse = plr:GetMouse()
if char.Humanoid.Health ~= 0 then
script.Parent.ClickDetector.MaxActivationDistance = 0
arms = {char:FindFirstChild("Left Arm"), char:FindFirstChild("Right Arm")}
torso = char:FindFirstChild("Torso")
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
local deb = true
if deb then
deb = false
local weld1 = Instance.new("Weld")
weld1.Part0 = torso
weld1.Parent = torso
weld1.Part1 = arms[1]
w######### CFrame.new(1.4,1.75,0) * CFrame.fromEulerAnglesXYZ(math.rad(180),.01,-.03)
welds[1] = weld1
local weld2 = Instance.new("Weld")
weld2.Part0 = torso
weld2.Parent = torso
weld2.Part1 = arms[2]
we######## CFrame.new(-1.4,1.75,0) * CFrame.fromEulerAnglesXYZ(math.rad(180),0.012,.03)
welds[2] = weld2
local weld3 = Instance.new("Weld")
weld3.Part0 = torso
weld3.Parent = script.Parent
weld3.Part1 = script.Parent
we######## CFrame.new(0,-3,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
welds[3] = weld3
end
end
local throw = true
mouse.Button1Down:connect(function()
if throw == true then
throw = false
---Undo Welds---
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
local deb = true
if deb then
deb = false
sh[1].Part1 = arms[1]
sh[2].Part1 = arms[2]
welds[1].Parent = nil
welds[2].Parent = nil
---Throwing---
p.Velocity=(mouse.Hit.p-p.Position).unit*100+Vector3.new(0,100,0)
p.CFrame=CFrame.new(char.Torso.Position,mouse.Hit.p)*CFrame.Angles(-math.pi/2,0,0)
wait()
welds[3].Parent = nil
end
end
end)
end) |