Dinizterz
|
  |
| Joined: 08 Oct 2008 |
| Total Posts: 4193 |
|
|
| 26 Jun 2013 11:35 PM |
NOTE: 400 lines of script incoming to use as a way to find the error I'm about to explain.
This is a modified Aircraft Seat Tool script, the script was made by Mark901 and modified by me to fit my wants, not just some value changes, some actual edits.
The script works fine, but then here's the error that happens in the output SOMETIMES: This Mouse is no longer active. (red text)
Error: What kind of event has to happen for a "mouse to be no longer active"? To get this error, I equip the tool, start the plane by pressing Y, everything works perfectly, I can steer, use the key controls, but then I unequip the tool, then press Y again, I can no longer steer the plane, it just goes in whatever direction its currently going. "This Mouse is no longer active" reads in the output. How do I make it so this doesn't happen? Suddenly not being able to steer a plane is unacceptable. Thanks.
bin = script.Parent plane = nil hold = false local debounce = false local planedebounce = false local stuntdebounce = false local controlling = false local currentspeed = 0 local turn = nil fly = false
player = bin.Parent.Parent repeat wait() until player char = player.Character ahum = char.Humanoid self = script.Parent spread = self.Spread tgls = player.GunSettings.ToggleSights tglsh = player.GunSettings.Shells armtrans = player.GunSettings.ArmTransparency currentclass = player.Backpack.PackValues.CurrentClass gui = player.PlayerGui.MGG.Bkgd
model = self.Subject.Value padre = model.mgpadre mgchamber = model.mgchamber
wepname = "1919 Browning" gunclass = "" Firerate = .1 flashtime = (Firerate/2) damrange = {35,45} normalspread = 5 crouchspread = normalspread - 10 zoom = 68 automatic = true burst = false shot = false putback = true down = false RayLength = 999
Bullet=Instance.new("Part") Bullet.Name="Bullet" Bullet.BrickColor=BrickColor.new("Bright yellow") Bullet.Anchored=true Bullet.CanCollide=false Bullet.Locked=true Bullet.Size=Vector3.new(1,1,1) Bullet.Transparency=.65 Bullet.formFactor=0 Bullet.TopSurface=0 Bullet.BottomSurface=0 mesh=Instance.new("SpecialMesh") mesh.Parent=Bullet mesh.MeshType="Brick" mesh.Name="Mesh" mesh.Scale=Vector3.new(.15,.15,1) r=game:service("RunService") debris = game:GetService("Debris")
function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end
function move(point, engine) local origincframe = engine:findFirstChild("Direction").cframe size = engine.Size
target = engine.Position+((point - engine.Position).unit*100) local dir = (target - engine.Position).unit local spawnPos = engine.Position left = engine.CFrame*CFrame.new(-size.x/2, 0, 0).p right = engine.CFrame*CFrame.new(size.x/2, 0, 0).p md = (target - engine.Position).magnitude
foebmd = engine.CFrame*CFrame.new(0, 0, -md).p toleft = (target -left).magnitude toright = (target -right).magnitude rot = ((foebmd - target).magnitude/10) local pos = spawnPos + (dir * 1) turn = math.rad((rot/10)*engine.TiltFactor.Value) if turn > math.rad(89) then turn = math.rad(89) end if toleft< toright and toleft >rot then engine:findFirstChild("Direction").cframe = CFrame.new(pos, pos + dir)*CFrame.fromEulerAnglesXYZ(0, 0, turn) elseif toleft > toright and toright >rot then engine:findFirstChild("Direction").cframe = CFrame.new(pos, pos + dir)*CFrame.fromEulerAnglesXYZ(0, 0, -turn) else engine:findFirstChild("Direction").cframe = CFrame.new(pos, pos + dir) end engine:findFirstChild("Direction").P = engine.TurnSpeed.Value end
function findPlane(player) local list = player.Character:GetChildren() for x = 1, #list do if (list[x].Name == "AircraftSeat") then return list[x] end end return nil end
function onButton2Down(mouse) local vehicle = findPlane(script.Parent.Parent.Parent) if vehicle ~= nil and debounce == false and planedebounce == false then if fly == false and taxi == false then return end debounce = true
controlling = true
while true do wait() local engine = vehicle local position = mouse.Hit local target = position.p move(target, engine) if planedebounce == true or controlling == false then break end end wait(0.1) debounce = false end end
function onButton2Up(mouse) controlling = false end
function onButton1Down(mouse) if ahum.Health < 1 then return end down = true while down do Spread = ((spread.Value)/100) if shot then local startpoint=padre.Position local mag=(mouse.Hit.p-startpoint).magnitude local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag)) fire(mouse.Hit.p+rndm) local mag2=((mouse.Hit.p+rndm)-startpoint).magnitude local rndm2=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm2) local rndm3=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm3) local rndm4=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm4) else local startpoint=padre.Position local mag=(mouse.Hit.p-startpoint).magnitude local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag)) fire(mouse.Hit.p+rndm) end wait(flashtime) padre.FlashBG.Flash.Visible = false wait(flashtime) if not automatic then break end end end
function onButton1Up(mouse) down = false end
function onSelected(mouse) mouse.Icon = "http://www.roblox.com/asset/?id=96378933" game.Workspace.CurrentCamera.CameraSubject = bin.Parent.Parent.Character.Head game.Workspace.CurrentCamera.CameraType = "Track" currentclass = gunclass mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) mouse.Button2Down:connect(function() onButton2Down(mouse) end) mouse.Button2Up:connect(function() onButton2Up(mouse) end) mouse.KeyDown:connect(onKeyDown) mouse.KeyUp:connect(onKeyUp) mouse.Move:connect(function() Fly(mouse) end) mouse.Idle:connect(function() Fly(mouse) end) end
function onDeselected(mouse) game.Workspace.CurrentCamera.CameraSubject = bin.Parent.Parent.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" currentclass = "" end
function Fly(mouse) local vehicle = findPlane(script.Parent.Parent.Parent) if (vehicle==nil) then return end vehicle.Thrust.velocity = (vehicle.CFrame.lookVector * currentspeed) + Vector3.new(0,vehicle.LiftTrim.Value/100,0) end
function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end
function raycast(startp, endp, ign) local vec=(endp-startp) if vec.magnitude<1000 then local hit,pos=game.Workspace:FindPartOnRay(Ray.new(startp,vec),ign) if hit and pos then if hit.Parent.className=="Tool" or hit.Parent.className=="Hat" then if hit.Parent.Parent ~= nil then if hit.Parent.Parent:findFirstChild("Humanoid")~=nil then return hit.Parent, pos end end end end return hit,pos end return nil end
function tagHumanoid(humanoid) local plr = player if plr ~= nil then local tag=Instance.new("ObjectValue") tag.Value=plr tag.Name="creator" tag.Parent=humanoid delay(2,function() if tag~=nil then tag.Parent=nil end end) end end
function ejectshell() if tglsh.Value == true then local shell = game.Workspace.BulletShellCasing:clone() shell.CFrame = mgchamber.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0) shell.Anchored = false shell.Velocity = mgchamber.CFrame.lookVector * -30 + Vector3.new(math.random(10,10),20,math.random(10,10)) shell.RotVelocity = Vector3.new(0,0,200) shell.Parent = game.Workspace debris:AddItem(shell, 1.5) end end
function fire(aim) t=r.Stepped:wait() local bullet=Bullet:clone() local totalDist=0 Lengthdist=-RayLength/.5 local startpoint=padre.Position local direction=(aim-startpoint) local cfrm=CFrame.new(startpoint, direction+startpoint) local vector=startpoint+(direction.Unit*999) if (startpoint-vector).magnitude<1000 then local hit,pos=raycast(startpoint,vector,player.Character) bullet.Parent=game.Workspace padre.FlashBG.Flash.Visible = true ejectshell() padre.Fire:Play() if hit~=nil then local humanoid=hit.Parent:FindFirstChild("Humanoid") if humanoid~=nil then local damage=math.random(damrange[1],damrange[2]) if hit.Name=="Head" then damage = damage * 1.6 elseif hit.Name=="Torso" then damage = damage else damage = damage * .75 end if humanoid.Health>0 then local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(self.Parent) if eplr then if eplr.TeamColor ~= plr.TeamColor then tagHumanoid(humanoid) humanoid:TakeDamage(damage) humanoid.Damaged.Value = true player.PlayerGui.GameHUD.Hit.Value = true end else tagHumanoid(humanoid) humanoid:TakeDamage(damage) player.PlayerGui.GameHUD.Hit.Value = true end end end if hit.Parent:findFirstChild("Integrity") then local il = hit.Parent.Integrity if il.Value > 0 then if il.TmCr.Value ~= player.TeamColor then local damage = math.random(damrange[1], damrange[2]) damage = damage * 0.25 il.Value = il.Value - damage player.PlayerGui.GameHUD.Hit.Value = true end end end if hit.Name == "Glass" then if hit.Transparency > 0.4 then hit.Transparency = hit.Transparency - 0.2 if not hit:findFirstChild("Broken") then for i = 0,5 do local d = Instance.new("Decal") d.Texture = "http://www.roblox.com/asset/?id=95912154" d.Face = i d.Name = "Broken" d.Parent = hit end end if hit.Transparency < 0.4 then for i = 1,5 do local b = game.Workspace.GlassBit:clone() b.Anchored = false b.Position = hit.Position - Vector3.new(math.random(-2,2),math.random(-1,1),math.random(-2,2)) b.BrickColor = hit.BrickColor b.Parent = game.Workspace debris:AddItem(b,math.random(2,8)) local ns = game.Workspace.GlassBreak:clone() ns.Parent = b ns.Pitch = (math.random(14,19)/10) ns:Play() end hit:BreakJoints() hit.Anchored = false hit.CanCollide = false end end end distance=(startpoint-pos).magnitude bullet.CFrame=cfrm*CFrame.new(0,0,-distance/2) bullet.Mesh.Scale=Vector3.new(.15,.15,distance) else bullet.CFrame=cfrm*CFrame.new(0,0,-RayLength/2) bullet.Mesh.Scale=Vector3.new(.15,.15,RayLength) end debris:AddItem(bullet,.05) debris:AddItem(sX, 2) end end
function onKeyDown(key) if (key~=nil) then key = key:lower() local vehicle = findPlane(script.Parent.Parent.Parent) if (vehicle==nil) then return end if key == "y" then fly = true vehicle.Direction.cframe = vehicle.CFrame vehicle.Direction.maxTorque = Vector3.new(4e3,4e3,4e3) vehicle.Thrust.maxForce = Vector3.new(9e20,9e20,9e20) model.BackRotor1.Transparency = 1 model.BackRotor2.Transparency = 1 model.Lod1.Transparency = 1 model.Lod2.Transparency = 1 model.Lod3.Transparency = 1 model.Lod4.Transparency = 1 model.BackRotorMesh.Transparency = 0.5 model.RotorMesh1.Transparency = 0.5 model.RotorMesh2.Transparency = 0.5 while fly == true do if currentspeed < vehicle.Speed.Value then currentspeed = currentspeed + 1 elseif currentspeed > vehicle.Speed.Value then currentspeed = currentspeed - 1 end wait((1-(vehicle.Acceleration.Value/10000))+0.01) if fly == false then break end end end if key == "x" then fly = false currentspeed = 0 vehicle.Direction.maxTorque = Vector3.new(0,0,0) vehicle.Thrust.maxForce = Vector3.new(0,0,0) model.BackRotor1.Transparency = 0 model.BackRotor2.Transparency = 0 model.Lod1.Transparency = 0 model.Lod2.Transparency = 0 model.Lod3.Transparency = 0 model.Lod4.Transparency = 0 model.BackRotorMesh.Transparency = 1 model.RotorMesh1.Transparency = 1 model.RotorMesh2.Transparency = 1 end if key == "p" then if model.Spotlight.Light.Enabled == false then model.Spotlight.Light.Enabled = true else model.Spotlight.Light.Enabled = false end end if key == "w" then if vehicle.Speed.Value < vehicle.MaxSpeed.Value then vehicle.Speed.Value = vehicle.Speed.Value + 10 end end if key == "s" then if vehicle.Speed.Value > vehicle.MinSpeed.Value then vehicle.Speed.Value = vehicle.Speed.Value - 10 end end --[[if (key=="'") and (bin.Locked.Value == false) then local repl = script:clone() repl.Parent = bin wait(1) script:remove() end]]-- if key == "l" and fly == true then vehicle.Direction.maxTorque = Vector3.new(4e3,0,4e3) local frame = vehicle:FindFirstChild("OriginCFrame") if frame ~= nil then vehicle.Direction.cframe = frame.Value end wait(2) vehicle.Direction.cframe = vehicle.CFrame vehicle.Direction.maxTorque = Vector3.new(4e3,4e3,4e3) end end end
function onKeyUp(key) if key == "f" then down = false end if (key~=nil) then key = key:lower() local vehicle = findPlane(script.Parent.Parent.Parent) if (vehicle==nil) then return end end end
bin.Selected:connect(onSelected) bin.Deselected:connect(onDeselected) -- Mark901 |
|
|
| Report Abuse |
|
Dinizterz
|
  |
| Joined: 08 Oct 2008 |
| Total Posts: 4193 |
|
|
| 27 Jun 2013 10:58 AM |
| Eh, posting huge amounts of code and asking what's wrong with it is what you're talking about, bragging is pointless/not what I'm doing. Just asking what kind of things have to happen for a "mouse to be no longer active", and the code is there to determine exactly what causes it. So there's two ways to approach it. |
|
|
| Report Abuse |
|