Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Having trouble removing a function from a script? (Better formatting).

Asked by 10 years ago

I'm trying to script a spitfire aircraft. I've taken a script and a few things from a seat that changes the plane's rotation (rotates it up/down so it can climb and descend, like a real airplane) and then combined them with a script that makes the plane go forward and reverse. Whatever I have tried, has not worked. The plane seat (in workspace) is called PlaneSeat, and inside, has the two following scripts, A BodyAngularVelocity, BodyGyro, BodyVelocity, and another Body Velocity. Then a configuration folder with the speed things (e.g, speed = 12). If anyone can, please remove the ability to change the plane's up/down rotation with W/S, but keep the ability to change the plane's up/down rotation with arrow keys. All I want is the option to change up/down with WS gone, because that controlls forward and backward movement.

SCRIPT 1:

01  local bv = script.Parent.BodyVelocity
02   
03  local bav = script.Parent.BodyAngularVelocity
04   
05  local seat = script.Parent
06   
07  local speed = 0
08  local maxSpeed = 30
09  local rotSpeed = 0
10  local maxRotSpeed = 2
11   
12  --Start the constant movement calculator
13  delay(0, function()
14      while true do
15          bv.velocity = seat.CFrame.lookVector * speed
16          bav.angularvelocity = Vector3.new(0, rotSpeed, 0)
17          wait()
18      end
19  end)
20   
21  seat.Changed:connect(function(prop)
22      if prop == "Throttle" then
23          if seat.Throttle == 1 or seat.Throttle == -1 then
24   
25              speed = maxSpeed * seat.Throttle
26   
27          elseif seat.Throttle == 0 then
28   
29              speed = 0
30   
31          end
32      elseif prop == "Steer" then
33          if seat.Steer == -1 or seat.Steer == 1 then
34   
35              rotSpeed = maxRotSpeed * -seat.Steer
36   
37          elseif seat.Steer == 0 then
38   
39              rotSpeed = 0
40   
41          end
42      end
43  end)
44   
45   -- That's script one (this isn't apart of the script, the sentence) which is 43 lines. The next script, is much, MUCH shorter. Here it is:
46   
47  local seat = script.Parent
48  local data = seat.Configuration
49  local owner = nil
50  local running = false
51  local x = 0
52  local y = 0

--the following two sentences are really long lines one under the other

1   seat.ChildAdded:connect(function(w) if w.className == "Weld" and w.Name == "SeatWeld" then local char=w.Part1.Parent local player=game.Players:FindFirstChild(char.Name) if player~=nil then owner=player seat.ChildRemoved:connect(function(w2) if w2 == w then owner = nil end end) seat.BodyVelocity.maxForce = Vector3.new(1,1,1) * data.MaxForce.Value seat.BodyGyro.maxTorque=Vector3.new(1,1,1)*50000 local spd = 0 local gui = seat.ScreenGui:clone() gui.Parent = player.PlayerGui gui.Frame.Faster.MouseButton1Click:connect(function() spd=math.min(spd + data.MaxSpeed.Value/20,data.MaxSpeed.Value) gui.Frame.Speed.Text=math.floor(spd) end) gui.Frame.Slower.MouseButton1Click:connect(function() spd=math.max(spd-data.MaxSpeed.Value/20,0) gui.Frame.Speed.Text=math.floor(spd) end) while owner==player do seat.BodyVelocity.velocity=seat.CFrame.lookVector*spd wait() end gui:remove() seat.BodyVelocity.velocity=Vector3.new(0,0,0) seat.BodyVelocity.maxForce=Vector3.new(0,0,0) seat.BodyGyro.maxTorque=Vector3.new(0,0,0) end end end)
2    
3   seat.Changed:connect(function() if not running then local cur = seat.Steer local cur2=seat.Throttle running=true while (cur ~= 0 or cur2 ~= 0) do y=y-seat.Steer*data.TurnSpeed.Value x = x - seat.Throttle * data.TurnSpeed.Value seat.BodyGyro.cframe = CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(y),0) * CFrame.Angles(math.rad(x),0,0) wait() end running=false end end)
1
That second script is burning my eyes, please learn how to skip lines and tab correctly... qq Perci1 4988 — 10y
0
@Perci1: Agreed. My brain hurts from trying to reformat that in my head. :Q Tkdriverx 514 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Maybe if you told me how to tab.

0
maybe if you told me how to tab, I could. freshieman 0 — 10y
Ad

Answer this question