222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
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)
|
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
This thread is the actual continuation of my previous thread (http://forum.roblox.com/Forum/ShowPost.aspx?PostID=183394566)
This is the actual issue, not the camera script. |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
I can't see why it would break the game when dying, though. |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
the only issue I can think of is that when the script is first applied to the player it would cause issues on respawn |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
while wait() do |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
no dice :( |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
i'm stumped |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
when they respawn something is looping too much. Maybe its the cframe |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
Yeah, the problem is that it works fine in Solo.
Online is where the trouble starts |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
Help pls |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
I will drag this thread up to the top if it means getting a fix |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
If it helps, this local script is in a tool (which you can probably guess by line 1) |
|
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
dang man |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
I swear it has to do with the "RandWeight" value in the weapon. I can't think of anything else |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
This is a bit out of my scope for troubleshooting. It works flawlessly in Solo so I can't step into the code. |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
Revive |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
I refuse to let you die |
|
|
KILL THE MONSTROSITY BEFORE IT REPRODUCES |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
We can do that after we find a resolution :( |
|
|
if script.Parent:findFirstChild("RandWeight") == nil then
script.Parent:remove()
end
end
:remove() keeps whatever you killed in memory so use :Destroy()
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)
this is probably infinitely looping somehow |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
yeah, stepping into the code in solo didn't prove anything useful |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
:( |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
honestly, swagcuzyolo is probably on to something. I just can't diagnose exactly what's throwing an exception if any |
|
222304Top 100 PosterJoin Date: 2008-05-26 Post Count: 24900 |
man |
|