222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
|
| 12 Feb 2016 04:50 PM |
I've been using two arm scripts to weld the player's arm to a position while allowing vertical movement. Problem is, if a player dies/resets while this script is active, they will crash on respawn. I can't seem to diagnose the problem, so I'm turning to you.
local Tool
local arm = nil local torso = nil local weld33 = nil -- right arm local welds = {}
function VectoDeg(origpoint,point1,point2) local torsocframeR = torso.CFrame*CFrame.Angles(0,1.57,0) local lookL = torsocframeR.lookVector local look = torso.CFrame.lookVector local dir = (point2-point1).unit local y = dir.Y local distout = math.sqrt(dir.X*dir.X+dir.Z*dir.Z) if (((origpoint+dir*5)-(origpoint+look*5)).magnitude > ((origpoint+dir*5)-(origpoint+lookL*5)).magnitude) or (((origpoint+dir*5)-(origpoint+lookL*-5)).magnitude > ((origpoint+dir*5)-(origpoint+look*-5)).magnitude) or ((((origpoint+dir*5)-(origpoint+look*5)).magnitude > ((origpoint+dir*5)-(origpoint+lookL*5)).magnitude) and (((origpoint+dir*5)-(origpoint+lookL*-5)).magnitude > ((origpoint+dir*5)-(origpoint+look*-5)).magnitude)) then if (((origpoint+dir*5)-(origpoint+lookL*5)).magnitude < ((origpoint+dir*5)-(origpoint+look*-5)).magnitude) then local bla = distout/math.sqrt(2) dir = (torso.Position-(torso.CFrame*CFrame.new(bla,-y,bla)).p).unit else local bla = distout/math.sqrt(2) dir = (torso.Position-(torso.CFrame*CFrame.new(-bla,-y,-bla)).p).unit end end local newpoint = origpoint+dir*.5 local cframe = CFrame.new(newpoint,newpoint-dir) cframe = cframe*CFrame.Angles(-1.57,3.14,-.65) weld33.C1 = cframe:inverse() weld33.C0 = torso.CFrame:inverse() end
function Equip(mouse) Tool = script.Parent wait(0.001) arm = Tool.Parent:FindFirstChild("Right Arm") torso = Tool.Parent:FindFirstChild("Torso") if arm ~= nil and torso ~= nil then local sh = torso:FindFirstChild("Right Shoulder") if sh ~= nil then local yes = true if yes then yes = false sh.Part1 = nil local weld1 = Instance.new("Weld") -- right arm weld33 = weld1 weld1.Part0 = torso weld1.Parent = torso weld1.Part1 = arm weld1.C1 = CFrame.new(-0.75, -0.4, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0) welds[1] = weld1 while true do wait(.01) VectoDeg((torso.CFrame*CFrame.new(1,.5,-.5)).p,(torso.CFrame*CFrame.new(1,.5,-.5)).p,script.Parent.Parent.Humanoid.TargetPoint) end end else print("sh") end else print("arms") end end
function Unequip(mouse) if arm ~= nil and torso ~= nil then local sh = torso:FindFirstChild("Right Shoulder") if sh ~= nil then local yes = true if yes then yes = false sh.Part1 = arm welds[1].Parent = nil end else print("sh") end else print("arms") end if script.Parent:findFirstChild("RandWeight") == nil then script.Parent:remove() end end
script.AncestryChanged:connect(function() if script:findFirstChild("secure") == nil then if script.Parent.className == "Tool" then script.Parent.Unequipped:connect(Unequip) script.Parent.Equipped:connect(Equip) script.Parent.ChildRemoved:connect(Unequip) local new = Instance.new("NumberValue") new.Name = "secure" new.Parent = script end end end) |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
|
| 12 Feb 2016 04:59 PM |
geez, this is a behemoth try using prints to find out exactly where it does wrong |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
|
| 12 Feb 2016 05:47 PM |
| Yea, problem is it works just fine in solo with no anomalies |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
|
| 13 Feb 2016 10:19 AM |
| The free models and bumps are making me not want to help you. |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
|
| 13 Feb 2016 10:20 AM |
"The free models and bumps are making me not want to help you."
thanks for the reply! |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
|
| 13 Feb 2016 10:47 AM |
| we need more friendly replies like that |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
| |
|