Removing a part makes script not work?
I have a tool in starter pack and in that tool I have a part named "Handle" also, a script that has:
01 | r = game:service( "RunService" ) |
06 | local equalizingForce = 236 / 1.2 |
09 | local ghostEffect = nil |
15 | function recursiveGetLift(node) |
17 | local c = node:GetChildren() |
18 | if (node:FindFirstChild( "Head" ) ~ = nil ) then head = node:FindFirstChild( "Head" ) end |
21 | if c [ i ] .className = = "Part" then |
22 | if (head ~ = nil and (c [ i ] .Position - head.Position).magnitude < 10 ) then |
23 | if c [ i ] .Name = = "Handle" then |
24 | m = m + (c [ i ] :GetMass() * equalizingForce * 1 ) |
26 | m = m + (c [ i ] :GetMass() * equalizingForce * gravity) |
30 | m = m + recursiveGetLift(c [ i ] ) |
36 | function onMassChanged(child, char) |
37 | print ( "Mass changed:" .. child.Name .. " " .. char.Name) |
38 | if (ghostEffect ~ = nil ) then |
39 | ghostEffect.force = Vector 3. new( 0 , recursiveGetLift(char) , 0 ) |
45 | function UpdateGhostState(isUnequipping) |
47 | if isUnequipping = = true then |
53 | if ghostEffect = = nil then |
54 | local char = Tool.Parent |
55 | if char = = nil then return end |
56 | ghostEffect = Instance.new( "BodyForce" ) |
57 | ghostEffect.Name = "GravityCoilEffect" |
58 | ghostEffect.force = Vector 3. new( 0 , recursiveGetLift(char) , 0 ) |
59 | ghostEffect.Parent = char.Head |
61 | massCon 1 = char.ChildAdded:connect( function (child) onMassChanged(child, char) end ) |
62 | massCon 2 = char.ChildRemoved:connect( function (child) onMassChanged(child, char) end ) |
72 | UpdateGhostState( false ) |
75 | function onUnequipped() |
76 | UpdateGhostState( true ) |
80 | script.Parent.Equipped:connect(onEquipped) |
81 | script.Parent.Unequipped:connect(onUnequipped) |
When I delete the handle, the script does not work :/
Help needed! Thanks.