Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --PUT IN STARTER GUI
- --All credit goes to xSoulStealerx
- create = function( tab )
- local obj = Instance.new( tab[1] )
- for i, v in pairs( tab ) do
- if i ~= 1 then
- obj[i] = v
- end
- end
- if obj:IsA("BasePart") then
- obj:breakJoints()
- end
- return obj
- end
- local player = game.Players.LocalPlayer
- repeat wait() until player.Character
- local _sgui = create{ "ScreenGui", Parent = player.PlayerGui, Name = "Controls" }
- local _txt = create{ "TextLabel", Parent = _sgui, Text = "Start/Stop:\t\t\tdouble-tap spacebar\nThrust:\t\t\t\thold spacebar\nTurn character:\trotate camera\nTilt offset:\t\t\tWASD\n\nCaution: may be hard to control for some people\nTip: hold space only when you feel like you need more force upwards",
- BackgroundTransparency = 1, TextColor3 = Color3.new(), Size = UDim2.new(0,0,0,0),
- Position = UDim2.new(0.5, -70, 0, 15), TextWrap = true, TextXAlignment = "Left", TextYAlignment = "Top"
- }
- local character = player.Character
- local humanoid = character:WaitForChild("Humanoid")
- local head = character:WaitForChild("Head")
- local torso = character:WaitForChild("Torso")
- local l_arm = character:WaitForChild("Left Arm")
- local r_arm = character:WaitForChild("Right Arm")
- local l_leg = character:WaitForChild("Left Leg")
- local r_leg = character:WaitForChild("Right Leg")
- game:service("ContentProvider"):Preload("rbxassetid://134145308")
- local heli_sound = create{ "Sound", SoundId = "rbxassetid://134145308", Volume = 0.15, Looped = true }
- local mouse = player:GetMouse()
- local camera = workspace.CurrentCamera
- local bodymass = 0
- local heli_axis_weld;
- local heli_rotor_weld;
- local heli_rotorspeed;
- local heli_rotorrot;
- local heli_targetthrottle;
- local heli_throttle;
- local collision_time;
- local bodyforce;
- local bodygyro;
- local tilt = CFrame.new();
- local fake_l_arm;
- local fake_r_arm;
- local fake_l_leg;
- local fake_r_leg;
- local heli_axeltop;
- local heli_axel;
- local heli_top;
- local getMass;
- local updateMass;
- local openPack;
- local closePack;
- local pack_open = false;
- local lastSpaceTick;
- keys = {}
- framekeys = {}
- mouse.KeyDown:connect( function(key)
- keys[ string.byte(key) ] = true
- framekeys[ string.byte(key) ] = true
- end )
- mouse.KeyUp:connect( function(key)
- keys[ string.byte(key) ] = false
- framekeys[ string.byte(key) ] = false
- end )
- lastSpaceTick = 0
- handleInput = function()
- if keys[32] == true then
- heli_targetthrottle = 1.5
- else
- heli_targetthrottle = 0.7
- end
- if not pack_open then
- heli_targetthrottle = 0
- end
- local t = CFrame.new()
- if keys[ string.byte'a' ] then
- t = t * CFrame.Angles( 0, 0, math.rad(25) )
- end
- if keys[ string.byte'd' ] then
- t = t * CFrame.Angles( 0, 0, math.rad(-25) )
- end
- if keys[ string.byte'w' ] then
- t = t * CFrame.Angles( math.rad(-25), 0, 0 )
- end
- if keys[ string.byte's' ] then
- t = t * CFrame.Angles( math.rad(25), 0, 0 )
- end
- tilt = t
- if framekeys[32] == true then
- if tick() - lastSpaceTick < 0.3 then
- lastSpaceTick = 0
- if pack_open then closePack() else openPack() end
- else
- lastSpaceTick = tick()
- end
- end
- end
- openPack = function()
- pack_open = true
- heli_throttle = 0.6
- heli_sound:Stop()
- heli_sound:Play()
- humanoid.PlatformStand = true
- bodygyro.Parent = heli_top
- fake_l_arm.CanCollide = true
- fake_r_arm.CanCollide = true
- fake_l_leg.CanCollide = true
- fake_r_leg.CanCollide = true
- game:service("ControllerService"):ClearAllChildren()
- end
- closePack = function()
- pack_open = false
- humanoid.PlatformStand = false
- bodygyro.Parent = nil
- fake_l_arm.CanCollide = false
- fake_r_arm.CanCollide = false
- fake_l_leg.CanCollide = false
- fake_r_leg.CanCollide = false
- coroutine.resume(coroutine.create(function()
- wait(0.2)
- Instance.new("HumanoidController",game:service("ControllerService"))
- end))
- end
- getMass = function( p )
- local mass = 0
- if p:IsA("BasePart") then
- mass = mass + p:GetMass()
- end
- for _, child in pairs( p:children() ) do
- mass = mass + getMass( child )
- end
- return mass
- end
- updateMass = function()
- bodymass = getMass( character )
- end
- collision_time = 0
- onCollision = function( hit )
- if collision_time <= 0 then
- local hit_speed = ( torso.Velocity - hit.Velocity ).magnitude
- if hit_speed > 65 and hit.CanCollide == true then
- collision_time = 0.8
- bodygyro.Parent = nil
- end
- end
- end
- torso.Touched:connect( onCollision )
- head.Touched:connect( onCollision )
- for _, child in pairs( character:children() ) do
- if child.Name == "HeliPack" then
- child:Destroy()
- end
- end
- heli_model = create{ "Model", Name = "HeliPack", Parent = character }
- script.Parent = heli_model
- fake_l_arm = create { "Part", Parent = heli_model, FormFactor = "Custom", Size = Vector3.new(1,2,1), CanCollide = true, Transparency = 1, Elasticity = 0.1, Friction = 0.8 }
- fake_r_arm = create { "Part", Parent = heli_model, FormFactor = "Custom", Size = Vector3.new(1,2,1), CanCollide = true, Transparency = 1, Elasticity = 0.1, Friction = 0.8 }
- fake_l_leg = create { "Part", Parent = heli_model, FormFactor = "Custom", Size = Vector3.new(1,2,1), CanCollide = true, Transparency = 1, Elasticity = 0.1, Friction = 0.8 }
- fake_r_leg = create { "Part", Parent = heli_model, FormFactor = "Custom", Size = Vector3.new(1,2,1), CanCollide = true, Transparency = 1, Elasticity = 0.1, Friction = 0.8 }
- create{ "Weld", Part0 = l_arm, Part1 = fake_l_arm, Parent = character }
- create{ "Weld", Part0 = r_arm, Part1 = fake_r_arm, Parent = character }
- create{ "Weld", Part0 = l_leg, Part1 = fake_l_leg, Parent = character }
- create{ "Weld", Part0 = r_leg, Part1 = fake_r_leg, Parent = character }
- fake_l_arm.Touched:connect( onCollision )
- fake_r_arm.Touched:connect( onCollision )
- fake_l_leg.Touched:connect( onCollision )
- fake_r_leg.Touched:connect( onCollision )
- heli_base = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model,
- Size = Vector3.new(1.8, 1.8, 0.2), BrickColor = BrickColor.new(1002)
- }
- heli_motor = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model,
- Size = Vector3.new(1.8, 1.7, 0.6), BrickColor = BrickColor.new(194)
- }
- heli_axel = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false,
- Size = Vector3.new(0.2, 3.1, 0.2), BrickColor = BrickColor.new(1002)
- }
- local _hp = create{ "Part", Parent = heli_model, TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", CanCollide = false, Size = Vector3.new(0.4, 0.2, 0.4), BrickColor = BrickColor.new("Black") }
- create{ "CylinderMesh", Parent = _hp}
- create{"Weld", Parent = heli_model, Part0 = heli_motor, Part1 = _hp, C0 = CFrame.new(0, 0.9, 0) }
- heli_axeltop = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false,
- Size = Vector3.new(0.4, 0.2, 0.4), BrickColor = BrickColor.new("Black")
- }
- heli_top = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false,
- Size = Vector3.new(0.2, 0.2, 0.2), Transparency = 1
- }
- create{ "Weld", Part0 = heli_axel, Part1 = heli_top, C0 = CFrame.new(0,1.5,0), Parent = heli_model }
- create{ "CylinderMesh", Parent = heli_axeltop }
- create{ "CylinderMesh", Parent = heli_axel }
- heli_rotor_weld = create{ "Weld", Parent = heli_model, Part0 = heli_axel, Part1 = heli_axeltop, C0 = CFrame.new(0,1.6,0) }
- clone_rotor = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", CanCollide = false,
- Size = Vector3.new(1.1, 0.2, 4.5), Transparency = 1
- }
- create { "Decal", Parent = clone_rotor, Texture = "rbxassetid://142889819", Face = "Top" }
- create { "Decal", Parent = clone_rotor, Texture = "rbxassetid://142889819", Face = "Bottom" }
- for angle = 0, 360-120, 120 do
- local part = clone_rotor:clone()
- create{ "BlockMesh", Parent = part, Scale = Vector3.new(1,0,1) }
- create{ "Weld", Part0 = heli_axeltop, Part1 = part, C0 = CFrame.Angles(0, math.rad(angle), 0), C1 = CFrame.new( 0, 0, -2.25 ), Parent = heli_model }
- part.Parent = heli_model
- end
- create{ "Weld", Part0 = torso, Part1 = heli_base, C0 = CFrame.new( 0, 0, 0.6 ), Parent = heli_model }
- create{ "Weld", Part0 = heli_base, Part1 = heli_motor, C0 = CFrame.new( 0, -0.05, 0.4 ), Parent = heli_model }
- heli_axis_weld = create{ "Weld", Part0 = heli_motor, Part1 = heli_axel, C0 = CFrame.new( 0, 2.3, 0 ), Parent = heli_model }
- heli_l_part = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.2, 1, 0.2), BrickColor = BrickColor.new(1002) }
- heli_r_part = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.2, 1, 0.2), BrickColor = BrickColor.new(1002) }
- heli_l_axel = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.2, 0.7, 0.2), BrickColor = BrickColor.new(1002) }
- heli_r_axel = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.2, 0.7, 0.2), BrickColor = BrickColor.new(1002) }
- heli_l_top = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.3, 0.2, 0.3), BrickColor = BrickColor.new("Black") }
- heli_r_top = create{ "Part", TopSurface = 0, BottomSurface = 0, FormFactor = "Custom", Parent = heli_model, CanCollide = false, Size = Vector3.new(0.3, 0.2, 0.3), BrickColor = BrickColor.new("Black") }
- create{"CylinderMesh", Parent = heli_l_top, Scale = Vector3.new(1,0.4,1) }
- create{"CylinderMesh", Parent = heli_r_top, Scale = Vector3.new(1,0.4,1) }
- create{"CylinderMesh", Parent = heli_l_part }
- create{"CylinderMesh", Parent = heli_r_part }
- create{"CylinderMesh", Parent = heli_l_axel, Scale = Vector3.new(0.8,1,0.8) }
- create{"CylinderMesh", Parent = heli_r_axel, Scale = Vector3.new(0.8,1,0.8) }
- create{ "Weld", Part0 = heli_motor, Part1 = heli_l_part, C0 = CFrame.new( -0.9, 0.65, 0 ) * CFrame.Angles(0,math.pi/2,0) * CFrame.Angles(-math.pi/2,0,0), C1 = CFrame.new(0, -0.5, 0), Parent = heli_model }
- create{ "Weld", Part0 = heli_motor, Part1 = heli_r_part, C0 = CFrame.new( 0.9, 0.65, 0 ) * CFrame.Angles(0,-math.pi/2,0) * CFrame.Angles(-math.pi/2,0,0), C1 = CFrame.new(0, -0.5, 0), Parent = heli_model }
- create{ "Weld", Part0 = heli_l_part, Part1 = heli_l_axel, C0 = CFrame.new( 0, 0.38, 0 ) * CFrame.Angles(0, 0, 1.4), C1 = CFrame.new(0, -0.3, 0), Parent = heli_model }
- create{ "Weld", Part0 = heli_r_part, Part1 = heli_r_axel, C0 = CFrame.new( 0, 0.38, 0 ) * CFrame.Angles(0, 0, -1.4), C1 = CFrame.new(0, -0.3, 0), Parent = heli_model }
- heli_l_weld = create{ "Weld", Part0 = heli_l_axel, Part1 = heli_l_top, C0 = CFrame.new( 0, 0.4, 0 ), Parent = heli_model }
- heli_r_weld = create{ "Weld", Part0 = heli_r_axel, Part1 = heli_r_top, C0 = CFrame.new( 0, 0.4, 0 ), Parent = heli_model }
- for angle = 0, 360-90, 90 do
- local part = clone_rotor:clone()
- part.Size = Vector3.new(0.6,0.2,1.6)
- create{ "BlockMesh", Parent = part, Scale = Vector3.new(1,0,1) }
- create{ "Weld", Part0 = heli_l_top, Part1 = part, C0 = CFrame.Angles(0, math.rad(angle), 0), C1 = CFrame.new( 0, 0, -0.8 ), Parent = heli_model }
- part.Parent = heli_model
- local part2 = clone_rotor:clone()
- part2.Size = Vector3.new(0.6,0.2,1.6)
- create{ "BlockMesh", Parent = part2, Scale = Vector3.new(1,0,1) }
- create{ "Weld", Part0 = heli_r_top, Part1 = part2, C0 = CFrame.Angles(0, math.rad(angle), 0), C1 = CFrame.new( 0, 0, -0.8 ), Parent = heli_model }
- part2.Parent = heli_model
- end
- heli_sound.Parent = heli_axeltop
- bodyforce = create{ "BodyForce", force = Vector3.new(), Parent = heli_top }
- bodygyro = create{ "BodyGyro", maxTorque = Vector3.new( 3000, 3000, 3000 ), P = 65, D = 7 }
- heli_rotorspeed = 0
- heli_rotorrot = 0
- heli_throttle = 0
- heli_targetthrottle = 0
- heli_sound:Play()
- updateMass()
- closePack()
- character.DescendantAdded:connect( updateMass )
- character.DescendantRemoving:connect( updateMass )
- local prevTime = tick()
- local a = 0
- loop = function()
- local currTime = tick()
- local delta = currTime - prevTime
- prevTime = currTime
- handleInput()
- if collision_time > 0 then
- collision_time = collision_time - delta
- else
- if pack_open and bodygyro.Parent ~= heli_top then
- bodygyro.Parent = heli_top
- end
- end
- heli_throttle = heli_throttle + (heli_targetthrottle - heli_throttle)*(0.06*delta*60.0)
- heli_rotorspeed = heli_throttle*3200
- heli_sound.Pitch = 1.9 + ( heli_throttle - 1 )*1
- if heli_throttle > 0.002 then
- if heli_sound.IsPaused then
- heli_sound:Play()
- end
- heli_sound.Volume = 0.28*(heli_throttle-0.002)
- else
- if heli_sound.IsPlaying then
- heli_sound:Pause()
- end
- end
- heli_rotorrot = heli_rotorrot + heli_rotorspeed*delta
- if heli_rotorrot > 180 then heli_rotorrot = heli_rotorrot - 360 elseif heli_rotorrot < -180 then heli_rotorrot = heli_rotorrot + 360 end
- heli_rotor_weld.C0 = CFrame.new(0, 1.6, 0) * CFrame.Angles( 0, math.rad(-heli_rotorrot), 0 )
- heli_l_weld.C1 = CFrame.Angles( 0, math.rad(heli_rotorrot), 0 )
- heli_r_weld.C1 = CFrame.Angles( 0, math.rad(heli_rotorrot), 0 )
- local cf = camera.CoordinateFrame * CFrame.Angles( math.rad(15), 0, 0 ) * tilt
- bodygyro.cframe = cf
- local up = ( torso.CFrame * CFrame.Angles( math.pi/2, 0, 0 )).lookVector
- local acc = Vector3.new(1,1,1)*196.2*heli_throttle
- bodyforce.force = up * acc * bodymass
- local hit, hitpos = workspace:FindPartOnRay( Ray.new( torso.CFrame.p, -up*3.1 ), character )
- if hit and pack_open and up.y > 0.88 and bodygyro.Parent == heli_top then
- if hit.CanCollide then
- closePack()
- end
- end
- for i, _ in pairs( framekeys ) do
- framekeys[i] = false
- end
- end
- oc = oc or function(f) return f end
- game:service("RunService").RenderStepped:connect( oc(loop) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement