Ad
Log in to vote
0

Having trouble removing a function from a script?

Asked by 7 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:

local bv = script.Parent.BodyVelocity

local bav = script.Parent.BodyAngularVelocity

local seat = script.Parent

local speed = 0
local maxSpeed = 30
local rotSpeed = 0
local maxRotSpeed = 2

--Start the constant movement calculator
delay(0, function()
    while true do
        bv.velocity = seat.CFrame.lookVector * speed
        bav.angularvelocity = Vector3.new(0, rotSpeed, 0)
        wait()
    end
end)

seat.Changed:connect(function(prop)
    if prop == "Throttle" then
        if seat.Throttle == 1 or seat.Throttle == -1 then

            speed = maxSpeed * seat.Throttle

        elseif seat.Throttle == 0 then

            speed = 0

        end
    elseif prop == "Steer" then
        if seat.Steer == -1 or seat.Steer == 1 then

            rotSpeed = maxRotSpeed * -seat.Steer

        elseif seat.Steer == 0 then

            rotSpeed = 0

        end
    end
end)

 -- 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:

local seat = script.Parent
local data = seat.Configuration
local owner = nil
local running = false
local x = 0
local y = 0


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

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)

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 answer

Log in to vote
0
Answered by 7 years ago

Sorry for the bad answer, I cant comment, but could you highlight all the codes, and click that 'Lua' button? It would be easier to understand after.

0
I have done so. freshieman 0 — 7y
0
I highleted it and clicked the lua button so it's easier to understand. freshieman 0 — 7y
0
thx TheBigCoder 25 — 7y
Ad

Answer this question