Advertisement
Aquarius_Raverus

hose

May 30th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.29 KB | None | 0 0
  1. --Original script by Luckymaxer
  2.  
  3. Model = script.Parent
  4. local SoundLoop
  5. local Whinny
  6. sound = false
  7. Players = game:GetService("Players")
  8. Debris = game:GetService("Debris")
  9. RunService = game:GetService("RunService")
  10.  
  11. Humanoid = Model:WaitForChild("Humanoid")
  12. Humanoid.Health = Humanoid.MaxHealth
  13. Seat = Model:WaitForChild("Seat")
  14. Torso = Model:WaitForChild("Torso")
  15.  
  16. InteractiveControl = script:WaitForChild("InteractiveControl")
  17.  
  18. Animations = {
  19.     Walk = {Animation = script:WaitForChild("Walk"), FadeTime = nil, Weight = nil, Speed = 7},
  20.     Idle = {Animation = script:WaitForChild("Idle"), FadeTime = nil, Weight = nil, Speed = 1},
  21.     Ride = {Animation = script:WaitForChild("Ride"), FadeTime = 0.25, Weight = nil, Speed = nil},
  22.     Rear = {Animation = script:WaitForChild("Rearing"), FadeTime = 0.25, Weight = nil, Speed = 2},
  23.     Jump = {Animation = script:WaitForChild("Jump"), FadeTime = nil, Weight = nil, Speed = 4},
  24. }
  25.  
  26. Walking = false
  27. Rider = nil
  28.  
  29. AngularVelocity = (Torso:FindFirstChild("BodyAngularVelocity") or Instance.new("BodyAngularVelocity"))
  30. AngularVelocity.Name = "BodyAngularVelocity"
  31. AngularVelocity.P = 1250
  32. AngularVelocity.AngularVelocity = Vector3.new(0, 0, 0)
  33. AngularVelocity.maxTorque = Vector3.new(0, math.huge, 0)
  34. AngularVelocity.Parent = Torso
  35.  
  36. Velocity = (Torso:FindFirstChild("BodyVelocity") or Instance.new("BodyVelocity"))
  37. Velocity.Name = "BodyVelocity"
  38. Velocity.maxForce = Vector3.new(math.huge, 0, math.huge)
  39. Velocity.Parent = Torso
  40.  
  41. WalkTrack = Humanoid:LoadAnimation(Animations.Walk.Animation)
  42. IdleTrack = Humanoid:LoadAnimation(Animations.Idle.Animation)
  43. RearTrack = Humanoid:LoadAnimation(Animations.Rear.Animation)
  44. JumpTrack = Humanoid:LoadAnimation(Animations.Jump.Animation)
  45.  
  46. Remotes = script:WaitForChild("Remotes")
  47. Remotes:ClearAllChildren()
  48.  
  49. LastJump = 0
  50. Disabled = false
  51.  
  52. ServerControl = (Remotes:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
  53. ServerControl.Name = "ServerControl"
  54. ServerControl.Parent = Remotes
  55.  
  56. ClientControl = (Remotes:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
  57. ClientControl.Name = "ClientControl"
  58. ClientControl.Parent = Remotes
  59.  
  60. function OnServerInvoke(player, Mode, Value)
  61.     if player ~= Rider or not Mode then
  62.         return
  63.     end
  64.     if Mode == "Jump" then
  65.         local Now = tick()
  66.         if (Now - LastJump) >= 1 then
  67.             LastJump = Now
  68.             Humanoid.Jump = true
  69.                 local Animation = Animations.Jump
  70.                 JumpTrack:Play(Animation.FadeTime, Animation.Weight, Animation.Speed)
  71.         end
  72.     elseif Mode == "Dismount" then
  73.         Dismount()
  74.     end
  75. end
  76.  
  77. ServerControl.OnServerInvoke = OnServerInvoke
  78.  
  79. Humanoid.Changed:connect(function(Property)
  80.     if Property == "Sit" and Humanoid.Sit then
  81.         Humanoid.Sit = false
  82.     end
  83. end)
  84.  
  85. Humanoid.Died:connect(function()
  86.     Disabled = true
  87.     Debris:AddItem(Model, 3)
  88.     Model:BreakJoints()
  89. end)
  90.  
  91. function InvokeClient(Mode, Value)
  92.     local ClientReturn = nil
  93.     pcall(function()
  94.         ClientReturn = ClientControl:InvokeClient(Rider, Mode, Value)
  95.     end)
  96.     return ClientReturn
  97. end
  98.  
  99. function Audio(ID, Location, Looped, Volume, Duration)
  100.     local Sound = Instance.new("Sound", Location)
  101.     Sound.SoundId = "http://www.roblox.com/asset/?id=" .. ID
  102.     Sound.Volume = Volume
  103.     Sound.Looped = Looped
  104.     if Duration then
  105.         game:GetService("Debris"):AddItem(Sound, Duration)
  106.     end
  107.     return Sound -- use as Audio(134973578, FrontTorso, true, 2)
  108. end
  109.  
  110. function Animate(Time)
  111.     if Humanoid.Health == 0 or Disabled then
  112.         return
  113.     end
  114.     --Walking
  115.     if not Walking and Torso.Velocity.magnitude > 1 then
  116.         IdleTrack:Stop()
  117.         local Animation = Animations.Walk
  118.         WalkTrack:Play(Animation.FadeTime, Animation.Weight, Animation.Speed)
  119.         Walking = true
  120.     end
  121.     if Walking and Torso.Velocity.magnitude < 1 then
  122.         WalkTrack:Stop()
  123.         local Animation = Animations.Idle
  124.         IdleTrack:Play(Animation.FadeTime, Animation.Weight, Animation.Speed)
  125.         Walking = false
  126.     end
  127.     --Motion
  128.     if Seat.Throttle ~= -1 then
  129.     Velocity.velocity = (Torso.CFrame.lookVector * Seat.Throttle * Humanoid.WalkSpeed*-1)
  130.     AngularVelocity.AngularVelocity = Vector3.new(0, (2 * -Seat.Steer), 0)--steer speed
  131.     else
  132.     Velocity.velocity = Vector3.new(0,0, 0) --Erase for moonwalk
  133.     Whinny = Audio(178645076, Torso, false, 3)
  134.         if sound==false then
  135.             sound = true
  136.                 local Animation = Animations.Rear
  137.                 RearTrack:Play(Animation.FadeTime, Animation.Weight, Animation.Speed)
  138.                 Whinny:Play()
  139.                 Whinny.Volume = 10
  140.                 Whinny.Pitch = 1
  141.                 wait(2)
  142.             sound = false
  143.         end
  144.     end
  145.        
  146.     --Sound
  147.     if not SoundLoop then
  148.         SoundLoop = Audio(134973578, Torso, true, 0)
  149.     elseif Torso.Velocity.magnitude > 1 then
  150.         if not SoundLoop.IsPlaying then
  151.             SoundLoop:Play()
  152.         end
  153.         SoundLoop.Volume = 10
  154.         SoundLoop.Pitch = ((1.2 - .55) * (Torso.Velocity.Magnitude / script.Parent.MaxSpeed.Value)) + .55
  155.     else
  156.         SoundLoop:Stop()
  157.     end
  158.     if JumpTrack.IsPlaying then
  159.         SoundLoop:Stop()
  160.     end
  161. end
  162.  
  163. function Dismount()
  164.     if Rider and Rider.Parent then
  165.         local Character = Rider.Character
  166.         if Character then
  167.             local Humanoid = nil
  168.             for i, v in pairs(Character:GetChildren()) do
  169.                 if v:IsA("Humanoid") then
  170.                     Humanoid = v
  171.                     break
  172.                 end
  173.             end
  174.             Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  175.             Humanoid.Jump = true
  176.         end
  177.     end
  178. end
  179.  
  180. function PlayerSeated(Child)
  181.     local function BreakWeld()
  182.         Debris:AddItem(Child, 0.5)
  183.         if Child and Child.Parent then
  184.             Child:Destroy()
  185.         end
  186.     end
  187.     if not Child:IsA("Weld") or not Child.Name == "SeatWeld" then
  188.         return
  189.     end
  190.     if Child.Part0 ~= Seat or not Child.Part1 or not Child.Part1.Parent then
  191.         return
  192.     end
  193.     Child.C1 = (Child.C1 * CFrame.new(0, 0.5, 0.375))
  194.     local character = Child.Part1.Parent
  195.     local humanoid = character:FindFirstChild("Humanoid")
  196.     local plr = Child.Part1.Parent.Name
  197.    
  198.     print(plr)
  199.    
  200.     game.Players[plr]:WaitForChild('onHorse').Value = true -- setting onhorse value.
  201.    
  202.     if humanoid then
  203.         print'test'
  204.         local Animation = Animations.Ride
  205.         RideTrack = humanoid:LoadAnimation(Animation.Animation)
  206.         RideTrack:Play(Animation.FadeTime, Animation.Weight, Animation.Speed)
  207.     end
  208.     local Player = Players:GetPlayerFromCharacter(character)
  209.     if not Player then
  210.         BreakWeld()
  211.         return
  212.     end
  213.     local PlayerGui = Player:FindFirstChild("PlayerGui")
  214.     if not PlayerGui then
  215.         BreakWeld()
  216.         return
  217.     end
  218.     InteractiveControlCopy = InteractiveControl:Clone()
  219.     local ServerCommunication = Instance.new("ObjectValue")
  220.     ServerCommunication.Name = "ServerControl"
  221.     ServerCommunication.Value = ServerControl
  222.     ServerCommunication.Parent = InteractiveControlCopy
  223.     InteractiveControlCopy.Disabled = false
  224.     InteractiveControlCopy.Parent = PlayerGui
  225.     Rider = Player.Name
  226.    
  227.     script.Parent.Rider.Value = Player
  228. end
  229.  
  230. function PlayerDismounted(Child)
  231.     if not Child:IsA("Weld") or not Child.Name == "SeatWeld" then
  232.         return
  233.     end
  234.     if not Child.Part1 or not Child.Part1.Parent then
  235.         return
  236.     end
  237.     local Player = Players:GetPlayerFromCharacter(Child.Part1.Parent)
  238.     print(Player.Name)
  239.    
  240.     Player:WaitForChild('onHorse').Value = false -- setting onhorse value
  241.     if not Player or Player ~= Rider then
  242.         return
  243.     end
  244.     if InteractiveControlCopy and InteractiveControlCopy.Parent then
  245.         InteractiveControlCopy:Destroy()
  246.     end
  247.     if RideTrack then
  248.         RideTrack:Stop()
  249.     end
  250.     Rider = nil
  251. end
  252.  
  253. RunService.Heartbeat:connect(Animate)
  254. Seat.ChildAdded:connect(PlayerSeated)
  255. Seat.ChildRemoved:connect(PlayerDismounted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement