Advertisement
AMisspelledUsernaem

Carpet

Jun 4th, 2023 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.25 KB | None | 0 0
  1. local tool=Instance.new('Tool')
  2. local handle=Instance.new('Part',tool)
  3. local mesh=Instance.new('SpecialMesh',handle)
  4.  
  5. local Sit=Instance.new('Animation',tool)
  6. local SitR15=Instance.new('Animation',tool)
  7.  
  8. Sit.Name='Sit'
  9. Sit.AnimationId='http://www.roblox.com/asset/?id=225279725'
  10.  
  11. SitR15.Name='SitR15'
  12. SitR15.AnimationId='rbxassetid://1239927101'
  13.  
  14. tool.Name='TwoSeaterRainbowMagicCarpet'
  15. tool.Grip=CFrame.new(-1.5,0,-.75)*CFrame.Angles(0,math.rad(-90),math.rad(-90))
  16. tool.TextureId='http://www.roblox.com/asset/?id=223080070'
  17.  
  18. handle.Name='Handle'
  19. handle.Size=Vector3.new(3,.5,6.5)
  20.  
  21. mesh.MeshId='http://www.roblox.com/asset/?id=223079737'
  22. mesh.TextureId='http://www.roblox.com/asset/?id=223080038'
  23. mesh.Scale=Vector3.new(1.125,1.125,1.4)
  24.  
  25.  
  26.  
  27.  
  28. local script=Instance.new('Script',tool)
  29.  
  30. --Made by Luckymaxer
  31.  
  32. Tool = script.Parent
  33. Handle = Tool:WaitForChild("Handle")
  34.  
  35. Players = game:GetService("Players")
  36. Debris = game:GetService("Debris")
  37.  
  38. RemovalMonitor = function(pare)
  39.     --Made by Luckymaxer
  40.     local script=Instance.new('Script',pare)
  41.    
  42.     local Model = script.Parent
  43.  
  44.     local Debris = game:GetService("Debris")
  45.  
  46.     local Removing = false
  47.  
  48.     local function RemoveModel()
  49.         if Removing then
  50.             return
  51.         end
  52.         local Parts = {}
  53.         for i, v in pairs(Model:GetChildren()) do
  54.             if v:IsA("Model") then
  55.                 table.insert(Parts, v)
  56.             end
  57.         end
  58.         if #Parts == 0 then
  59.             Removing = true
  60.             Model.Name = ""
  61.             Debris:AddItem(Model, 1)
  62.         end
  63.     end
  64.  
  65.     Model.ChildRemoved:connect(function(Child)
  66.         RemoveModel()
  67.     end)
  68.  
  69.     RemoveModel()
  70. end
  71.  
  72. CarpetPieces = {
  73.     {MeshId = 223079795, Angle = 160},
  74.     {MeshId = 223079835, Angle = 100},
  75.     {MeshId = 223079888, Angle = 100},
  76.     {MeshId = 223079981, Angle = 160},
  77. }
  78.  
  79. CarpetSize = Vector3.new(6, 0.5, 6.5)
  80.  
  81. BaseUrl = "http://www.roblox.com/asset/?id="
  82.  
  83. Rate = (1 / 10)
  84.  
  85. BasePart = Instance.new("Part")
  86. BasePart.Material = Enum.Material.Plastic
  87. BasePart.Shape = Enum.PartType.Block
  88. BasePart.TopSurface = Enum.SurfaceType.Smooth
  89. BasePart.BottomSurface = Enum.SurfaceType.Smooth
  90. BasePart.FormFactor = Enum.FormFactor.Custom
  91. BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
  92. BasePart.CanCollide = false
  93. BasePart.Locked = true
  94.  
  95. ColorPart = BasePart:Clone()
  96. ColorPart.Name = "ColorPart"
  97. ColorPart.Reflectance = 0.25
  98. ColorPart.Transparency = 0.1
  99. ColorPart.Material = Enum.Material.SmoothPlastic
  100. ColorPart.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
  101. ColorPart.BackSurface = Enum.SurfaceType.SmoothNoOutlines
  102. ColorPart.TopSurface = Enum.SurfaceType.SmoothNoOutlines
  103. ColorPart.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
  104. ColorPart.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
  105. ColorPart.RightSurface = Enum.SurfaceType.SmoothNoOutlines
  106. ColorPart.Size = Vector3.new(1, 1, 1)
  107. ColorPart.Anchored = true
  108. ColorPart.CanCollide = false
  109. ColorMesh = Instance.new("SpecialMesh")
  110. ColorMesh.Name = "Mesh"
  111. ColorMesh.MeshType = Enum.MeshType.FileMesh
  112. ColorMesh.MeshId = (BaseUrl .. "9856898")
  113. ColorMesh.TextureId = (BaseUrl .. "1361097")
  114. ColorMesh.Scale = (ColorPart.Size * 2) --Default mesh scale is 1/2 the size of a 1x1x1 brick.
  115. ColorMesh.Offset = Vector3.new(0, 0, 0)
  116. ColorMesh.VertexColor = Vector3.new(1, 1, 1)
  117. ColorMesh.Parent = ColorPart
  118. ColorLight = Instance.new("PointLight")
  119. ColorLight.Name = "Light"
  120. ColorLight.Brightness = 50
  121. ColorLight.Range = 8
  122. ColorLight.Shadows = false
  123. ColorLight.Enabled = true
  124. ColorLight.Parent = ColorPart
  125.  
  126. RainbowColors = {
  127.     Vector3.new(1, 0, 0),
  128.     Vector3.new(1, 0.5, 0),
  129.     Vector3.new(1, 1, 0),
  130.     Vector3.new(0, 1, 0),
  131.     Vector3.new(0, 1, 1),
  132.     Vector3.new(0, 0, 1),
  133.     Vector3.new(0.5, 0, 1)
  134. }
  135.  
  136. Animations = {
  137.     Sit = {Animation = Tool:WaitForChild("Sit"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
  138. }
  139.  
  140. Grips = {
  141.     Normal = CFrame.new(-1.5, 0, -0.75, 0, 0, -1, -1, 8.90154915e-005, 0, 8.90154915e-005, 1, 0),
  142.     Flying = CFrame.new(0, 0.5, -0.125, -1, 0, -8.99756625e-009, -8.99756625e-009, 8.10000031e-008, 1, 7.28802977e-016, 0.99999994, -8.10000103e-008)
  143. }
  144.  
  145. Flying = false
  146. ToolEquipped = false
  147.  
  148. ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
  149. ServerControl.Name = "ServerControl"
  150. ServerControl.Parent = Tool
  151.  
  152. ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
  153. ClientControl.Name = "ClientControl"
  154. ClientControl.Parent = Tool
  155.  
  156. Handle.Transparency = 0
  157. Tool.Grip = Grips.Normal
  158. Tool.Enabled = true
  159.  
  160. function Clamp(Number, Min, Max)
  161.     return math.max(math.min(Max, Number), Min)
  162. end
  163.  
  164. function TransformModel(Objects, Center, NewCFrame, Recurse)
  165.     local Objects = ((type(Objects) ~= "table" and {Objects}) or Objects)
  166.     for i, v in pairs(Objects) do
  167.         if v:IsA("BasePart") then
  168.             v.CFrame = NewCFrame:toWorldSpace(Center:toObjectSpace(v.CFrame))
  169.         end
  170.         if Recurse then
  171.             TransformModel(v:GetChildren(), Center, NewCFrame, true)
  172.         end
  173.     end
  174. end
  175.  
  176. function Weld(Parent, PrimaryPart)
  177.     local Parts = {}
  178.     local Welds = {}
  179.     local function WeldModel(Parent, PrimaryPart)
  180.         for i, v in pairs(Parent:GetChildren()) do
  181.             if v:IsA("BasePart") then
  182.                 if v ~= PrimaryPart then
  183.                     local Weld = Instance.new("Weld")
  184.                     Weld.Name = "Weld"
  185.                     Weld.Part0 = PrimaryPart
  186.                     Weld.Part1 = v
  187.                     Weld.C0 = PrimaryPart.CFrame:inverse()
  188.                     Weld.C1 = v.CFrame:inverse()
  189.                     Weld.Parent = PrimaryPart
  190.                     table.insert(Welds, Weld)
  191.                 end
  192.                 table.insert(Parts, v)
  193.             end
  194.             WeldModel(v, PrimaryPart)
  195.         end
  196.     end
  197.     WeldModel(Parent, PrimaryPart)
  198.     return Parts, Welds
  199. end
  200.  
  201. function CleanUp()
  202.     Handle.Transparency = 0
  203.     for i, v in pairs(Tool:GetChildren()) do
  204.         if v:IsA("BasePart") and v ~= Handle then
  205.             v:Destroy()
  206.         end
  207.     end
  208. end
  209.  
  210. function CreateRainbow(Length)
  211.     local RainbowModel = Instance.new("Model")
  212.     RainbowModel.Name = "RainbowPart"
  213.     for i, v in pairs(RainbowColors) do
  214.         local Part = ColorPart:Clone()
  215.         Part.Name = "Part"
  216.         Part.Size = Vector3.new(0.5, 0.5, Length)
  217.         Part.CFrame = Part.CFrame * CFrame.new((Part.Size.X * (i - 1)), 0, 0)
  218.         Part.Mesh.Scale = (Part.Size * 2)
  219.         Part.Mesh.VertexColor = v
  220.         Part.Light.Color = Color3.new(v.X, v.Y, v.Z)
  221.         Part.Parent = RainbowModel
  222.     end
  223.     local RainbowBoundingBox = BasePart:Clone()
  224.     RainbowBoundingBox.Name = "BoundingBox"
  225.     RainbowBoundingBox.Transparency = 1
  226.     RainbowBoundingBox.Size = RainbowModel:GetModelSize()
  227.     RainbowBoundingBox.Anchored = true
  228.     RainbowBoundingBox.CanCollide = false
  229.     RainbowBoundingBox.CFrame = RainbowModel:GetModelCFrame()
  230.     RainbowBoundingBox.Parent = RainbowModel
  231.     return RainbowModel
  232. end
  233.  
  234. function GetRainbowModel()
  235.     local ModelName = (Player.Name .. "'s Rainbow")
  236.     local Model = game:GetService("Workspace"):FindFirstChild(ModelName)
  237.     if not Model then
  238.         Model = Instance.new("Model")
  239.         Model.Name = ModelName
  240.         RemovalMonitor(Model)
  241.     end
  242.     return Model
  243. end
  244.  
  245. function CheckIfAlive()
  246.     return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
  247. end
  248.  
  249. function Activated()
  250.     if not Tool.Enabled then
  251.         return
  252.     end
  253.     Tool.Enabled = false
  254.     Flying = not Flying
  255.     if Flying then
  256.         CleanUp()
  257.         Handle.Transparency = 1
  258.         local CarpetParts = {}
  259.         Seat = Instance.new("Seat")
  260.         Seat.Name = "Seat"
  261.         Seat.Transparency = 1
  262.         Seat.Material = Enum.Material.Plastic
  263.         Seat.Shape = Enum.PartType.Block
  264.         Seat.TopSurface = Enum.SurfaceType.Smooth
  265.         Seat.BottomSurface = Enum.SurfaceType.Smooth
  266.         Seat.FormFactor = Enum.FormFactor.Custom
  267.         Seat.Size = Vector3.new(0.5, 0.2, 0.5)
  268.         Seat.CanCollide = true
  269.         Seat.Locked = true
  270.         Seat.Disabled = false
  271.         local SeatWeld = Instance.new("Weld")
  272.         SeatWeld.Name = "Weld"
  273.         SeatWeld.Part0 = Handle
  274.         SeatWeld.Part1 = Seat
  275.         SeatWeld.C0 = (CFrame.new(-1.5, 0, -3.25) * CFrame.Angles(0, math.pi, 0))
  276.         SeatWeld.C1 = CFrame.new(0, 0, 0)
  277.         SeatWeld.Parent = Seat
  278.         Seat.Parent = Tool
  279.         for i, v in pairs(CarpetPieces) do
  280.             local CarpetPart = BasePart:Clone()
  281.             CarpetPart.Size = Vector3.new(CarpetSize.X, CarpetSize.Y, (CarpetSize.Z / #CarpetPieces))
  282.             local Mesh = Instance.new("SpecialMesh")
  283.             Mesh.MeshType = Enum.MeshType.FileMesh
  284.             Mesh.MeshId = (BaseUrl .. v.MeshId)
  285.             Mesh.TextureId = (BaseUrl .. "223080038")
  286.             Mesh.Scale = Vector3.new(2, 1.125, 1.5)
  287.             Mesh.VertexColor = Vector3.new(1, 1, 1)
  288.             Mesh.Offset = Vector3.new(0, 0, 0)
  289.             Mesh.Parent = CarpetPart
  290.             local Weld = Instance.new("Weld")
  291.             Weld.Part0 = Handle
  292.             Weld.Part1 = CarpetPart
  293.             local XOffset = (((i == 1 or i == #CarpetPieces) and -0.005) or 0)
  294.             local YOffset = ((-((Handle.Size.Z / 2) - (CarpetPart.Size.Z / 2))) + ((CarpetPart.Size.Z * (i - 1))) + ((i == 2 and 0.85) or (i == 3 and 1.1) or (i == #CarpetPieces and 1.97) or 0))
  295.             Weld.C1 = CFrame.new(0, XOffset, YOffset)
  296.             Weld.Parent = CarpetPart
  297.             table.insert(CarpetParts, {Part = CarpetPart, Weld = Weld, InitialCFrame = Weld.C0, Angle = v.Angle})
  298.             CarpetPart.Parent = Tool
  299.         end
  300.  
  301.         spawn(function()
  302.             InvokeClient("PlayAnimation", Animations.Sit)
  303.             Tool.Grip = Grips.Flying
  304.         end)
  305.  
  306.         Torso.Anchored = true
  307.         delay(.2,function()
  308.             Torso.Anchored = false
  309.             Torso.Velocity = Vector3.new(0,0,0)
  310.             Torso.RotVelocity = Vector3.new(0,0,0)
  311.         end)
  312.  
  313.         FlightSpin = Instance.new("BodyGyro")
  314.         FlightSpin.Name = "FlightSpin"
  315.         FlightSpin.P = 10000
  316.         FlightSpin.maxTorque = Vector3.new(FlightSpin.P, FlightSpin.P, FlightSpin.P)*100
  317.         FlightSpin.cframe = Torso.CFrame
  318.  
  319.         FlightPower = Instance.new("BodyVelocity")
  320.         FlightPower.Name = "FlightPower"
  321.         FlightPower.velocity = Vector3.new(0, 0, 0)
  322.         FlightPower.maxForce = Vector3.new(1,1,1)*1000000
  323.         FlightPower.P = 1000
  324.  
  325.         FlightHold = Instance.new("BodyPosition")
  326.         FlightHold.Name = "FlightHold"
  327.         FlightHold.P = 100000
  328.         FlightHold.maxForce = Vector3.new(0, 0, 0)
  329.         FlightHold.position = Torso.Position
  330.  
  331.         FlightSpin.Parent = Torso
  332.         FlightPower.Parent = Torso
  333.         FlightHold.Parent = Torso
  334.  
  335.         spawn(function()
  336.             local LastPlace = nil
  337.             while Flying and ToolEquipped and CheckIfAlive() do
  338.  
  339.                 local CurrentPlace = Handle.Position
  340.                 local Velocity = Torso.Velocity
  341.                 Velocity = Vector3.new(Velocity.X, 0, Velocity.Z).magnitude
  342.  
  343.                 if LastPlace and Velocity > 10 then
  344.  
  345.                     spawn(function()
  346.                         local Model = GetRainbowModel()
  347.                         local Distance = (LastPlace - CurrentPlace).magnitude
  348.                         local Length = Distance + 3.5
  349.  
  350.                         local RainbowModel = CreateRainbow(Length)
  351.                         local RainbowCFrame = CFrame.new((LastPlace + (CurrentPlace - LastPlace).unit * (Distance / 2)), CurrentPlace)
  352.  
  353.                         TransformModel(RainbowModel, RainbowModel:GetModelCFrame(), RainbowCFrame, true)
  354.                         Debris:AddItem(RainbowModel, 1)
  355.                         RainbowModel.Parent = Model
  356.  
  357.                         if Model and not Model.Parent then
  358.                             Model.Parent = game:GetService("Workspace")
  359.                         end
  360.  
  361.                         LastPlace = CurrentPlace
  362.                     end)
  363.                 elseif not LastPlace then
  364.                     LastPlace = CurrentPlace
  365.                 end
  366.  
  367.                 wait(Rate)
  368.             end
  369.         end)
  370.     elseif not Flying then
  371.         Torso.Velocity = Vector3.new(0, 0, 0)
  372.         Torso.RotVelocity = Vector3.new(0, 0, 0)
  373.         for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
  374.             if v and v.Parent then
  375.                 v:Destroy()
  376.             end
  377.         end
  378.         if Seat and Seat.Parent and Seat.Occupant and Seat.Occupant:IsA("Humanoid") then
  379.             local humanoid = Seat.Occupant
  380.             humanoid.Sit = false
  381.         end
  382.         CleanUp()
  383.         spawn(function()
  384.             Tool.Grip = Grips.Normal
  385.             InvokeClient("StopAnimation", Animations.Sit)
  386.         end)
  387.     end
  388.  
  389.     wait(2)
  390.  
  391.     Tool.Enabled = true
  392. end
  393. function Equipped(Mouse)
  394.     Character = Tool.Parent
  395.     Humanoid = Character:FindFirstChild("Humanoid")
  396.     Torso = Character:FindFirstChild("HumanoidRootPart")
  397.     Player = Players:GetPlayerFromCharacter(Character)
  398.     if not CheckIfAlive() then
  399.         return
  400.     end
  401.     if Humanoid then
  402.         if Humanoid.RigType == Enum.HumanoidRigType.R15 then
  403.             Animations = {
  404.                 Sit = {Animation = Tool:WaitForChild("SitR15"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
  405.             }
  406.         else
  407.             Animations = {
  408.                 Sit = {Animation = Tool:WaitForChild("Sit"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
  409.             }
  410.         end
  411.     end
  412.     Tool.Grip = Grips.Normal
  413.     ToolEquipped = true
  414. end
  415. function Unequipped()
  416.     Flying = false
  417.     for i, v in pairs({FlightSpin, FlightPower, FlightHold}) do
  418.         if v and v.Parent then
  419.             v:Destroy()
  420.         end
  421.     end
  422.     CleanUp()
  423.     Handle.Transparency = 0
  424.     ToolEquipped = false
  425. end
  426. function OnServerInvoke(player, mode, value)
  427.     if player ~= Player or not ToolEquipped or not value or not CheckIfAlive() then
  428.         return
  429.     end
  430. end
  431. function InvokeClient(Mode, Value)
  432.     local ClientReturn = nil
  433.     pcall(function()
  434.         ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
  435.     end)
  436.     return ClientReturn
  437. end
  438. CleanUp()
  439. ServerControl.OnServerInvoke = OnServerInvoke
  440. Tool.Activated:connect(Activated)
  441. Tool.Equipped:connect(Equipped)
  442. Tool.Unequipped:connect(Unequipped)
  443.  
  444. tool.Parent=owner.Backpack
  445.  
  446. NLS([[
  447. --Made by Luckymaxer
  448.  
  449. Tool = script.Parent
  450. Handle = Tool:WaitForChild("Handle")
  451.  
  452. Players = game:GetService("Players")
  453. RunService = game:GetService("RunService")
  454.  
  455. Camera = game:GetService("Workspace").CurrentCamera
  456.  
  457. Animations = {}
  458. LocalObjects = {}
  459.  
  460. ServerControl = Tool:WaitForChild("ServerControl")
  461. ClientControl = Tool:WaitForChild("ClientControl")
  462.  
  463. Rate = (1 / 60)
  464.  
  465. SpeedMultiplier = 1.5
  466.  
  467. CameraSpeed = {
  468.     X = 40*SpeedMultiplier,
  469.     Z = 60*SpeedMultiplier
  470. }
  471.  
  472. Controls = {
  473.     Forward = {
  474.         Mode = false,
  475.         Keys = {Key = "w", ByteKey = 17}
  476.     },
  477.     Backward = {
  478.         Mode = false,
  479.         Keys = {Key = "s", ByteKey = 18}
  480.     },
  481.     Left = {
  482.         Mode = false,
  483.         Keys = {Key = "a", ByteKey = 20}
  484.     },
  485.     Right = {
  486.         Mode = false,
  487.         Keys = {Key = "d", ByteKey = 19}
  488.     },
  489. }
  490.  
  491. ToolEquipped = false
  492.  
  493. function HandleFlightControl()
  494.     if not CheckIfAlive() then
  495.         return
  496.     end
  497.     if FightMonitor then
  498.         FightMonitor:disconnect()
  499.     end
  500.     FightMonitor = Torso.ChildAdded:connect(function(Child)
  501.         if Flying then
  502.             return
  503.         end
  504.         if Child.Name == "FlightHold" then
  505.             local FlightSpin = Torso:FindFirstChild("FlightSpin")
  506.             local FlightPower = Torso:FindFirstChild("FlightPower")
  507.             local FlightHold = Torso:FindFirstChild("FlightHold")
  508.             if not FlightSpin or not FlightPower or not FlightHold then
  509.                 return
  510.             end
  511.             Flying = true
  512.             Humanoid.WalkSpeed = 0
  513.             Humanoid.PlatformStand = true
  514.             Humanoid.AutoRotate = false
  515.             DisableJump(true)
  516.             Torso.Velocity = Vector3.new(0, 0, 0)
  517.             Torso.RotVelocity = Vector3.new(0, 0, 0)
  518.             local IsMoving = false
  519.             while Flying and FlightSpin.Parent and FlightPower.Parent and FlightHold.Parent and CheckIfAlive() do
  520.                 local NewPush = Vector3.new(0, 0, 0)
  521.                 local ForwardVector = Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(0, 0, -1))
  522.                 local SideVector = Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(-1, 0, 0))
  523.  
  524.                 local CoordinateFrame = Camera.CoordinateFrame
  525.                 local localControlVector = CFrame.new(Vector3.new(0,0,0),CoordinateFrame.lookVector*Vector3.new(1,0,1)):vectorToObjectSpace(Humanoid.MoveDirection)
  526.  
  527.                 NewPush = NewPush + ((ForwardVector * CameraSpeed.Z * -localControlVector.z) or NewPush)
  528.                 NewPush = NewPush + ((SideVector * CameraSpeed.X * -localControlVector.x) or NewPush)
  529.  
  530.  
  531.  
  532.                 --NewPush = (NewPush + (((Controls.Forward.Mode and not Controls.Backward.Mode) and (ForwardVector * CameraSpeed.Z)) or ((not Controls.Forward.Mode and Controls.Backward.Mode) and (ForwardVector * CameraSpeed.Z * -1)) or NewPush))
  533.                 --NewPush = (NewPush + (((Controls.Left.Mode and not Controls.Right.Mode) and (SideVector * CameraSpeed.X)) or ((not Controls.Left.Mode and Controls.Right.Mode) and (SideVector * CameraSpeed.X * -1)) or NewPush))
  534.                 FlightSpin.cframe = CFrame.new(Vector3.new(0, 0, 0), ForwardVector)
  535.                 if NewPush.magnitude < 1 then
  536.                     FlightHold.maxForce = Vector3.new((FlightHold.P * 100), (FlightHold.P * 100), (FlightHold.P * 100))
  537.                     FlightPower.maxForce = Vector3.new(0, 0, 0)
  538.                     if IsMoving then
  539.                         FlightHold.position = Torso.Position
  540.                     end
  541.                     IsMoving = false
  542.                 else
  543.                     IsMoving = true
  544.                     FlightHold.maxForce = Vector3.new(0, 0, 0)
  545.                     FlightPower.maxForce = Vector3.new((FlightPower.P * 100), (FlightPower.P * 100), (FlightPower.P * 100))
  546.                 end
  547.                 FlightPower.velocity = NewPush
  548.                 wait(Rate)
  549.             end
  550.             Flying = false
  551.             if CheckIfAlive() then
  552.                 Torso.Velocity = Vector3.new(0, 0, 0)
  553.                 Torso.RotVelocity = Vector3.new(0, 0, 0)
  554.                 Humanoid.WalkSpeed = 16
  555.                 Humanoid.PlatformStand = false
  556.                 Humanoid.AutoRotate = true
  557.                 DisableJump(false)
  558.                 Humanoid:ChangeState(Enum.HumanoidStateType.Freefall)
  559.             end
  560.         end
  561.     end)
  562. end
  563.  
  564. function SetAnimation(mode, value)
  565.     if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  566.         for i, v in pairs(Animations) do
  567.             if v.Animation == value.Animation then
  568.                 v.AnimationTrack:Stop()
  569.                 table.remove(Animations, i)
  570.             end
  571.         end
  572.         local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
  573.         table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack})
  574.         AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
  575.     elseif mode == "StopAnimation" and value then
  576.         for i, v in pairs(Animations) do
  577.             if v.Animation == value.Animation then
  578.                 v.AnimationTrack:Stop()
  579.                 table.remove(Animations, i)
  580.             end
  581.         end
  582.     end
  583. end
  584.  
  585. function DisableJump(Boolean)
  586.     if PreventJump then
  587.         PreventJump:disconnect()
  588.     end
  589.     if Boolean then
  590.         PreventJump = Humanoid.Changed:connect(function(Property)
  591.             if Property ==  "Jump" then
  592.                 Humanoid.Jump = false
  593.             end
  594.         end)
  595.     end
  596. end
  597.  
  598. function CheckIfAlive()
  599.     return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent and Player and Player.Parent) and true) or false)
  600. end
  601.  
  602. function KeyPress(Key, Down)
  603.     local Key = string.lower(Key)
  604.     local ByteKey = string.byte(Key)
  605.     for i, v in pairs(Controls) do
  606.         if Key == v.Keys.Key or ByteKey == v.Keys.ByteKey then
  607.             Controls[i].Mode = Down
  608.         end
  609.     end
  610. end
  611.  
  612. function Equipped(Mouse)
  613.     Character = Tool.Parent
  614.     Player = Players:GetPlayerFromCharacter(Character)
  615.     Humanoid = Character:FindFirstChild("Humanoid")
  616.     Torso = Character:FindFirstChild("HumanoidRootPart")
  617.     ToolEquipped = true
  618.     if not CheckIfAlive() then
  619.         return
  620.     end
  621.     Mouse.KeyDown:connect(function(Key)
  622.         KeyPress(Key, true)
  623.     end)
  624.     Mouse.KeyUp:connect(function(Key)
  625.         KeyPress(Key, false)
  626.     end)
  627.     Spawn(HandleFlightControl)
  628. end
  629.  
  630. function Unequipped()
  631.     Flying = false
  632.     LocalObjects = {}
  633.     for i, v in pairs(Animations) do
  634.         if v and v.AnimationTrack then
  635.             v.AnimationTrack:Stop()
  636.         end
  637.     end
  638.     for i, v in pairs({PreventJump, FightMonitor}) do
  639.         if v then
  640.             v:disconnect()
  641.         end
  642.     end
  643.     for i, v in pairs(Controls) do
  644.         Controls[i].Mode = false
  645.     end
  646.     Animations = {}
  647.     ToolEquipped = false
  648. end
  649.  
  650. function InvokeServer(mode, value)
  651.     local ServerReturn
  652.     pcall(function()
  653.         ServerReturn = ServerControl:InvokeServer(mode, value)
  654.     end)
  655.     return ServerReturn
  656. end
  657.  
  658. function OnClientInvoke(mode, value)
  659.     if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  660.         SetAnimation("PlayAnimation", value)
  661.     elseif mode == "StopAnimation" and value then
  662.         SetAnimation("StopAnimation", value)
  663.     elseif mode == "PlaySound" and value then
  664.         value:Play()
  665.     elseif mode == "StopSound" and value then
  666.         value:Stop()
  667.     end
  668. end
  669.  
  670. ClientControl.OnClientInvoke = OnClientInvoke
  671. Tool.Equipped:connect(Equipped)
  672. Tool.Unequipped:connect(Unequipped)
  673. ]],tool)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement