of     1   

As8D
#45165986Wednesday, April 06, 2011 6:49 AM GMT

Hi! I'm trying to mix 2 kinds of script, both normal scripts ect. It's a binocular script & welding-script, that make a cool "onTaken"-effect. But when I try to "undisable" both the scripts at same time, the binocular-script make a glitch and say "trying to upvalue "gui" (a nil value)" or something like that, but the gui should exist? It's just wierdo! Here's the binocular script: local dropped = false local equipped = false local gui = nil local player = nil local look = nil local whereToZoom = nil local zoomFactor = 20 local balance = 0 local initPos = nil local bodyPos = nil local binocBodyPos = nil local binocPoint = nil local animup = nil function createBinocPoint(h) whereToZoom = h.CFrame.lookVector.unit binocPoint = Instance.new("Part") binocPoint.Size = Vector3.new(1,1,1) binocPoint.Transparency = 1 binocPoint.CFrame = h.CFrame binocPoint.Parent = game.Workspace binocPoint.Position = Vector3.new(h.Position.x,h.Position.y,h.Position.z) + (whereToZoom * 17) binocPoint.CanCollide = false binocBodyPos = Instance.new("BodyPosition") binocBodyPos.P = 10000 binocBodyPos.D = 1000 binocBodyPos.maxForce = Vector3.new(10000,10000,10000) binocBodyPos.position = binocPoint.Position binocBodyPos.Parent = binocPoint local binocBodyGyro = Instance.new("BodyGyro") binocBodyGyro.cframe = binocPoint.CFrame binocBodyGyro.P = 100000 binocBodyGyro.D = 1 binocBodyGyro.maxTorque = Vector3.new(100000,100000,100000) binocBodyGyro.Parent = binocPoint local sound = script.Parent.Handle.zoomOut:clone() sound.Parent = binocPoint end script.Parent.Changed:connect(function(pr) if pr == "Parent" then if script.Parent.Parent == game.Workspace then --dropped dropped = true script.Parent.Handle.CanCollide = true elseif dropped then dropped = false script.Parent.Handle.CanCollide = false end end end) script.Parent.Equip.Changed:connect(function(mouse) if script.Parent.Equip.Value == true then equipped = true player = game:service("Players"):GetPlayerFromCharacter(script.Parent.Parent) gui = script.Parent.BinocGui:clone() gui.Parent = player.PlayerGui -- enable failsafe wait() --needed, strange error occurs when no wait is put here local fail = script.Parent.CamFocusFailsafe:clone() fail.Disabled = false fail.Tool.Value = script.Parent fail.Target.Value = player.Character.Humanoid --put in character fail.Parent = script.Parent.Parent --- local turnpressed = false --- --mouse.Button1Down:wait() gui.ActivateFrame.Activate.Visible = false gui.ActivateFrame.Deactivate.Visible = true gui.ControlsFrame.Visible = true gui.BinocFrame.Visible = true local torso = script.Parent.Parent:FindFirstChild("Torso", false) local head = script.Parent.Parent:FindFirstChild("Head", false) createBinocPoint(head) script.Parent.CamFocus.Value = binocPoint initPos = torso.Position bodyPos = Instance.new("BodyPosition") bodyPos.position = torso.Position bodyPos.maxForce = Vector3.new(90000,90000,90000) bodyPos.P = 90000 bodyPos.D = 10 bodyPos.Name = "bodyPos" bodyPos.Parent = torso humanoid = script.Parent.Parent:FindFirstChild("Humanoid", false) --script.Parent.GripPos = Vector3.new(1.5,-1.3,-0.3) local head = script.Parent.Parent:FindFirstChild("Head", false) look = head.CFrame.lookVector.unit --end) --[[ gui.ActivateFrame.Deactivate.MouseButton1Down:connect(function() gui.ActivateFrame.Activate.Visible = true gui.ActivateFrame.Deactivate.Visible = false gui.BinocFrame.Visible = false gui.ControlsFrame.Visible = false script.Parent.CamFocus.Value = nil if bodyPos then bodyPos:remove() bodyPos = nil end script.Parent.GripPos = Vector3.new(0, 0, 0.7) binocPoint:remove() balance = 0 end)]] --[[ gui.ControlsFrame.PanLeft.MouseButton1Down:connect(function() if binocPoint and balance > -1 then balance = balance - 1 local leftX = (look.x * math.cos(-math.pi/2)) - (look.z * math.sin(-math.pi/2)) local leftZ = (look.x * math.sin(-math.pi/2)) - (look.z * math.cos(-math.pi/2)) binocBodyPos.position = Vector3.new(binocPoint.Position.x + (leftX* zoomFactor), binocPoint.Position.y,binocPoint.Position.z + (leftZ* zoomFactor)) end end) gui.ControlsFrame.PanRight.MouseButton1Down:connect(function() if binocPoint and balance < 1 then balance = balance + 1 local rightX = (look.x * math.cos(math.pi/2)) - (look.z * math.sin(math.pi/2)) local rightZ = (look.x * math.sin(math.pi/2)) - (look.z * math.cos(math.pi/2)) binocBodyPos.position = Vector3.new(binocPoint.Position.x + (rightX * zoomFactor) , binocPoint.Position.y,binocPoint.Position.z + (rightZ* zoomFactor)) end end)]] gui.ControlsFrame.ZoomIn.MouseButton1Down:connect(function() if binocPoint then local diff = Vector2.new(binocPoint.Position.x - initPos.x,binocPoint.Position.z - initPos.z) if diff.magnitude < 150 then binocPoint.zoomOut:Play() binocBodyPos.position = Vector3.new(binocPoint.Position.x + (whereToZoom.x * zoomFactor), binocPoint.Position.y,binocPoint.Position.z + (whereToZoom.z * zoomFactor)) end end end) gui.ControlsFrame.ZoomOut.MouseButton1Down:connect(function() if binocPoint then xMag = binocPoint.Position.x - initPos.x zMag = binocPoint.Position.z - initPos.z totalDist = xMag + zMag local diff = Vector2.new(binocPoint.Position.x - initPos.x,binocPoint.Position.z - initPos.z) if diff.magnitude > 30 then binocPoint.zoomOut:Play() binocBodyPos.position = Vector3.new(binocPoint.Position.x + (whereToZoom.x * -zoomFactor), binocPoint.Position.y,binocPoint.Position.z + (whereToZoom.z * -zoomFactor)) end end end) elseif script.Parent.Equip.Value == false then equipped = false script.Parent.CamFocus.Value = nil if bodyPos then bodyPos:remove() bodyPos = nil end if gui then gui:remove() gui = nil end end end) Here's the welding-script (it has a localscript inside call'd "Failsafe2" inside, so it's not the problem): --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() 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, -1, 0) * CFrame.fromEulerAnglesXYZ(-1, 0, 0) --Bring_Arm_Up animation for i = 0, 1, 0.05 do wait() RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.7*i, 0, -0.6*i) --LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i) --LW.C1 = CFrame.new(-0.3*i, 0.5+1.2*i, 0) end wait() script.Parent.Equip.Value = true end) --griptcf = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-math.pi/2+0.5, 0, 0) script.Parent.Unequipped:connect(function() --Bring_Arm_Down animation if player.PlayerGui:FindFirstChild("BinocGui") ~= nil then player.PlayerGui:FindFirstChild("BinocGui"):remove() end scr = script.Failsafe2:clone() scr.Parent = player.PlayerGui scr.Disabled = false script.Parent.Equip.Value = false for i = 1, 0, -0.05 do wait() RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.7*i, 0, -0.6*i) --LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i) --LW.C1 = CFrame.new(-0.3*i, 0.5+1.2*i, 0) end RW.Parent = nil --LW.Parent = nil RSH.Parent = player.Character.Torso --LSH.Parent = player.Character.Torso end) local a = false local co = nil --OMGHAX mouseclick Thx. for reading this! -As xD
currydude
#45166702Wednesday, April 06, 2011 8:30 AM GMT

I think... The GUI problem that you stated at the beginning, it will not go if you disable the script, hence why you get a nil value. So you may have to get a third party script to remove the GUI. I think. I don't work with binoculars and GUI's to often, you may have to find someone who has done this to take a look. It may be worthwhile looking in free models to see how other people have done a similar thing, stealing would be bad, but there is no harm in looking for a solution; besides, they are there for a reason. Currydude
Robert00001
#45167711Wednesday, April 06, 2011 11:14 AM GMT

Don't try to stop people from replying Curry,
As8D
#45169208Wednesday, April 06, 2011 12:57 PM GMT

Naah. It's also the problem that when you combinate the 2 scripts, the tool will always get "dropped" and taken again. What a spam xP I think I've outfigurered how to solve this: 1) Clone the right arm and make the onTaken-function connect to that (because it seems only to happen when the "right shoulder"'s parent is nil (when the arm goes down again, the right shoulder will come back.)... and make the normal right arm transparent... and of course delete the "rightGrip" and make another into the "false" right arm. :P 2) Edit the... I think, C1 or C0 in the "right shoulder"? :P It's maybe like a weld with more functions... xD I don't work much with motors xP 3) Just as I said before... disable 1 of them. So... what do you think?
[rfa#hidefromsearch]
#45169456Wednesday, April 06, 2011 1:14 PM GMT

[rfa#hidefromsearch]
As8D
#45208315Thursday, April 07, 2011 6:30 AM GMT

Noh answers :/ Only tha stalkzor! xD

    of     1