CVWJoin Date: 2010-02-25 Post Count: 7780 |
Ok does it have anything to do with the tool?
PlaneFlyer script:
creativeval = 0
bin=script.Parent
plane=nil
hold=false
vSpeed = 0
taxiing = true
CID = 0
NuubVal = 0
local debounce = false
local planedebounce = false
local stuntdebounce = false
local controlling = false
PlaneOn = false
SpeedInc = 0
Firing = false
XO = true
function move(point, Engine)
local origincframe = Engine:findFirstChild("BodyGyro").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)
Engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(9000, 9000, 9000)
if toleftrot and speedcvb.Value >= script.Parent.MinSpeed.Value then
Engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos + dir)*CFrame.fromAxisAngle( Vector3.new(0, 0, rot) , math.pi/ 30 )
elseif toleft > toright and toright >rot and speedcvb.Value >= script.Parent.MinSpeed.Value then
Engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos + dir)*CFrame.fromAxisAngle( Vector3.new(0, 0,-rot) , math.pi/ 30 )
else
Engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos + dir)
end
wait(0.1)
Engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(0, 0, 0)
Engine:findFirstChild("BodyGyro").cframe = origincframe
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 findPlane(player)
local list = player.Character:GetChildren()
for x = 1, #list do
if (list[x].className == "Model") then
if list[x]:findFirstChild("Engine") ~= nil then
return list[x]
end
end
end
end
function onButton1Down(mouse)
local vehicle = findPlane(script.Parent.Parent.Parent)
if vehicle ~= nil and debounce == false and planedebounce == false then
debounce = true
controlling = true
while true do
wait()
local Engine = vehicle.Engine
local position = mouse.Hit
local target = position.p
if Engine:findFirstChild("FlyScript") ~= nil then
move(target, Engine)
end
if planedebounce == true or
controlling == false then break end
end
wait(.1)
debounce = false
end
end
function onButton1Up(mouse)
controlling = false
end
function onSelected(mouse)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.KeyDown:connect(onKeyDown)
mouse.KeyUp:connect(onKeyUp)
abcd = findPlane(script.Parent.Parent.Parent)
TailNo = script.Parent.TailNumber.Value
MaxSpeed = script.Parent.MaxSpeed.Value
if game.Players.LocalPlayer.PlayerGui:findFirstChild("PlaneStats") == nil then
Gui = script.Parent.PlaneStats:clone()
Gui.Parent = game.Players.LocalPlayer.PlayerGui
Gui.Frame.PN.Text = script.Parent.Plane.Value
interface(Gui)
end
end
function interface(G)
while true do
wait(0.1)
if NuubVal >= 30 then
NuubVal = 0
if CID == 0 then
abcd.Name = game.Players.LocalPlayer.Name
CID = 1
elseif CID == 1 then
abcd.Name = TailNo
CID = 2
elseif CID == 2 then
abcd.Name = script.Parent.Plane.Value
CID = 0
end
end
if abcd.Engine:findFirstChild("Speed") ~= nil then
abcd.Engine.Speed.Value = abcd.Engine.Speed.Value+SpeedInc
if abcd.Engine.Speed.Value < 0 then abcd.Engine.Speed.Value = 0
elseif abcd.Engine.Speed.Value > MaxSpeed then abcd.Engine.Speed.Value = MaxSpeed end
end
if G ~= nil then
PS = G.Frame
vSpeed = (math.sqrt((abcd.Engine.Velocity.x)^2+(abcd.Engine.Velocity.y)^2+(abcd.Engine.Velocity.z)^2)*20)
PS.Coords.Text = "("..math.ceil(abcd.Engine.Position.x)..","..math.ceil(abcd.Engine.Position.z)..")"
PS.Alt.Text = (math.ceil(abcd.Engine.Position.y*20)-10).." ft"
PS.Speed.Text = math.floor(vSpeed/1.68781).." Knots"
PS.VertSpeed.Text = math.ceil(abcd.Engine.Velocity.y*20).." ft/sec"
CF = abcd.Engine.CFrame*CFrame.new(0,0,-10)
WW = CF.p
DX = abcd.Engine.Position.x-WW.x
DZ = abcd.Engine.Position.z-WW.z
PS.Compass.Point.Position = UDim2.new(0,18-(DX*2),0,18-(DZ*2))
end
if Firing == true then
if XO == true then
Bullet = game.Lighting.Bullet:clone()
Bullet.Script.Disabled = false
Bullet.Parent = plane
Bullet.CFrame = plane.Engine.CFrame*CFrame.new(0,0,-26)
Bullet.Anchored = false
Bullet.Transparency = 0
XO = false
else
if Bullet ~= nil then
Bullet:remove()
end
XO = true
end
end
NuubVal = NuubVal + 1
end
end
function onKeyUp(key)
if (key~=nil) then
key = key:lower()
if (key=="m") or (key=="n") and PlaneOn == true then
SpeedInc = 0
end
if (key=="v") and Bullet ~= nil then
Firing = false
if Bullet ~= nil then
Bullet:remove()
end
end
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
plane = vehicle
local Engine = vehicle.Engine
if (key=="") then
Engine.Kill.Value = 0
end
if (key=="e") then
local spd = plane.Engine:findFirstChild("Speed")
if PlaneOn == true then
SpeedInc = -1
PlaneOn = false
F = plane:getChildren()
for f=1,#F do
if F[f].Name == "PropOn" then F[f].Transparency = 1
elseif F[f].Name == "PropOff" then F[f].Transparency = 0
end
end
else
PlaneOn = true
F = plane:getChildren()
for f=1,#F do
if F[f].Name == "PropOn" then F[f].Transparency = 0.4
elseif F[f].Name == "PropOff" then F[f].Transparency = 1
end
end
local power = plane.Engine:findFirstChild("FlyScript")
if (power == nil) then
local fly = script.FlyScript:clone()
fly.Disabled = false
fly.Parent = plane.Engine
speedcvb = script.Parent.Speed:clone()
speedcvb.Parent = plane.Engine
end
end
end
if (key=="n") and PlaneOn == true then
SpeedInc = -1
end
if (key=="m") and PlaneOn == true then
SpeedInc = 1
end
if key == "y" and plane.Engine:findFirstChild("Cargo Drop") ~= nil and plane.Engine.Position.y > 250 then
if plane.Crate:findFirstChild("Crate") == nil then
L = game.Lighting.Crate:clone()
L.Parent = plane.Crate
VVV = plane.Engine.Position
L.CFrame = CFrame.new(VVV)
end
end
if (key=="g") then
if plane.Engine:findFirstChild("Lemon Drop") ~= nil and plane.Engine.Position.y > 3 then
L = game.Lighting.Lemon:clone()
L.Parent = plane.Lemons
VVV = plane.Engine.Position
L.CFrame = CFrame.new(VVV)
end
R = plane:getChildren()
for r=1,#R do
if R[r].Name == "LGear" then
if R[r].Transparency == 1 then
R[r].Transparency = 0 else R[r].Transparency = 1 end
end
end
end
--[[if (key=="v") and PlaneOn == true and plane:findFirstChild("Weapon") ~= nil then
Firing = true
end ]]
if (key=="k") and planedebounce == false then
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y -0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y -0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y -0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y -0.7, 0)
end
if (key=="h") and planedebounce == false then
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y +0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y +0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y +0.7, 0)
wait()
Engine.RotVelocity = Vector3.new(0, Engine.RotVelocity.y +0.7, 0)
return end
if (key=="j") and planedebounce == false then
local body = plane.Engine.BodyGyro
body.maxTorque = Vector3.new(9000, 9000, 9000)
local position = Engine.CFrame * Vector3.new(0, 0.5, -4)
local dir = position - Engine.Position
dir = computeDirection(dir)
local spawnPos = Engine.Position
local pos = spawnPos + (dir * 8)
body.cframe = CFrame.new(pos, pos + dir)
wait(.2)
body.maxTorque = Vector3.new(0, 0, 0)
end
if (key=="l") and planedebounce == false then
local body = plane.Engine.BodyGyro
body.maxTorque = Vector3.new(9000, 0, 0)
local frame = plane:FindFirstChild("OriginCFrame")
if frame ~= nil then
body.cframe = frame.Value
end
wait(0.1)
body.maxTorque = Vector3.new(0, 0, 0)
end
if (key=="u") and planedebounce == false then
local body = plane.Engine.BodyGyro
body.maxTorque = Vector3.new(9000, 9000, 9000)
local position = Engine.CFrame * Vector3.new(0, -0.5, -4)
local dir = position - Engine.Position
dir = computeDirection(dir)
local spawnPos = Engine.Position
local pos = spawnPos + (dir * 8)
body.cframe = CFrame.new(pos, pos + dir)
wait(.2)
body.maxTorque = Vector3.new(0, 0, 0)
end
end
end
bin.Selected:connect(onSelected)
FlyScript: (not the same as the above)
local engine = script.Parent.Parent.Engine
local position = engine.Position
bv = engine.BodyVelocity
bv.velocity = Vector3.new(0,0,0)
while true do
wait(.1)
if script.Parent.Position.y < 0.5 or script.Parent.Kill.Value < 1 then
Player = game.Players:findFirstChild(script.Parent.Parent.Parent.Name)
Player.PlayerGui.PlaneStats:remove()
if Player.PlayerGui:findFirstChild("MissionObjective") ~= nil then
Player.PlayerGui.MissionObjective:remove()
end
if Player.PlayerGui:findFirstChild("FlightPlanner") ~= nil then
Player.PlayerGui.FlightPlanner:remove()
end
game.Lighting.MainGui:clone().Parent = Player.PlayerGui
Player.Backpack.Plane:remove()
Player.Character.Head.Anchored = true
script.Parent.Parent:remove()
end
if script.Parent:findFirstChild("Speed") ~= nil then
spd = script.Parent.Speed.Value
minspd = script.Parent.Parent.MinSpeed.Value
serv = script.Parent.Parent.ServiceCeiling.Value
dir = engine.CFrame.lookVector
if spd >= minspd and spd < script.Parent.Parent.MaxSpeed.Value+5 then
bv.maxForce = Vector3.new(1e12,1e12,1e12)
else
bv.maxForce = Vector3.new(1e12,0,1e12)
end
if engine.Position.y > (serv+10)/20 then
bv.maxForce = Vector3.new(1e12,0,1e12)
end
bv.velocity = dir * ((spd*0.084391)-(.25*engine.Velocity.y))
end
end
|