Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script
- local vUpdate=require(script:WaitForChild("VehicleUpdater"))
- local player=nil
- function stopAnims(target)
- local Humanoid = target.Humanoid
- local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
- for _,v in pairs(ActiveTracks) do
- v:Stop()
- end
- end
- script.Parent.ChildAdded:connect(function(v)
- if v:IsA("Weld") and v.Name=="SeatWeld" then --Hey, players use this to sit!
- player=game.Players:GetPlayerFromCharacter(v.Part1.Parent)
- if player then --WE GOT ONE!!!
- script.VControls:Clone().Parent=player.PlayerGui
- end
- end
- end)
- script.Parent.ChildRemoved:connect(function(v)
- if v:IsA("Weld") and v.Name=="SeatWeld" and player then
- local scr=player.PlayerGui:FindFirstChild("VControls")
- if scr then scr:Destroy() end
- end
- end)
- script.Parent.ChildRemoved:connect(function(v)
- if v:IsA("Weld") and v.Name=="SeatWeld" then
- local plr = game.Players:FindFirstChild(v.Part1.Parent.Name)
- local char = plr.Character
- stopAnims(char)
- end
- end)
- -- Local Script
- local pl=game.Players.LocalPlayer
- local cam=workspace.CurrentCamera
- local seat=cam.CameraSubject
- local vehicle=seat.Parent
- local boost = false
- local db = false
- local UIS = game:GetService("UserInputService")
- UIS.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.LeftShift and boost == false and db == false then
- db = true
- boost = true
- wait(.2)
- boost = false
- wait(4)
- db = false
- end
- end)
- local vUpdate = require(seat.Engine:FindFirstChild("VehicleUpdater"))
- while wait() do
- vUpdate(pl,vehicle,boost)
- end
- -- Module Script
- local handling = ( 2 ) *.05;
- local maxTurn = ( 4 );
- local acceleration = ( 1.5 ) *.03;
- local topSpeed = ( 5 ) + 60;
- local visualTorque = ( 5 ) *.1
- local boospeed=0
- local debounce=false
- local zoomin=false
- local Animations = script.Parent.Parent.Parent.Animations
- local LastAnim
- local function boost(boospe,vel,seat,cam, player,vehicle,canboost)
- local boostSound=seat.Boost
- boostSound:Play()
- script.Parent.Parent.Parent.Base.Trail1.Enabled = true
- script.Parent.Parent.Parent.Base.Trail2.Enabled = true
- debounce=true
- boospeed=boospe
- vel.velocity=vel.velocity+seat.CFrame.lookVector*boospe
- for i=1,15 do
- cam.FieldOfView =(70+i)
- game:GetService("RunService").RenderStepped:wait()
- end
- cam.FieldOfView = 85
- --cam.FieldOfView=10
- wait(.5)
- for i=1,15 do
- cam.FieldOfView =(85-i)
- game:GetService("RunService").RenderStepped:wait()
- end
- cam.FieldOfView = 70
- script.Parent.Parent.Parent.Base.Trail1.Enabled = false
- script.Parent.Parent.Parent.Base.Trail2.Enabled = false
- debounce=false
- UpdateHoverboard(player,vehicle,canboost)
- end
- function stopAnims(target)
- local Humanoid = target.Humanoid
- local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
- for _,v in pairs(ActiveTracks) do
- v:Stop()
- end
- end
- function UpdateAnims(target,currentAnim)
- if currentAnim == "Moving" and currentAnim ~= LastAnim and script.Parent.Parent:FindFirstChild("SeatWeld") then
- LastAnim = currentAnim
- stopAnims(target)
- if script.Parent.Parent:FindFirstChild("SeatWeld") then
- target.Humanoid:LoadAnimation(Animations.Moving):Play()
- end
- elseif currentAnim == "Idle" and currentAnim ~= LastAnim and script.Parent.Parent:FindFirstChild("SeatWeld") then
- LastAnim = currentAnim
- stopAnims(target)
- if script.Parent.Parent:FindFirstChild("SeatWeld") then
- target.Humanoid:LoadAnimation(Animations.Idle):Play()
- end
- elseif script.Parent.Parent:FindFirstChild("SeatWeld") == nil then
- stopAnims(target)
- game:GetService("Debris"):AddItem(script.Parent.Parent.Parent, .5)
- end
- end
- function UpdateHoverboard(player,vehicle,canboost)
- if script.Parent.Parent:FindFirstChild("SeatWeld") then
- else
- stopAnims(player.Character)
- script.Parent.Parent.Idle:Stop()
- script.Parent.Parent.Boost:Stop()
- local seat=vehicle:FindFirstChild("VehicleSeat")
- local angv=seat:FindFirstChild("angv")
- local vel=seat:FindFirstChild("vel")
- local gyro=seat:FindFirstChild("gy")
- vel.velocity=vel.velocity:Lerp(Vector3.new(0, 0, 0), 1)
- end
- end
- return function(player,vehicle,canboost)
- if script.Parent.Parent:FindFirstChild("SeatWeld") == nil then
- stopAnims(player.Character)
- script.Parent.Parent.Idle:Stop()
- script.Parent.Parent.Boost:Stop()
- local seat=vehicle:FindFirstChild("VehicleSeat")
- local angv=seat:FindFirstChild("angv")
- local vel=seat:FindFirstChild("vel")
- local gyro=seat:FindFirstChild("gy")
- vel.velocity=vel.velocity:Lerp(Vector3.new(0, 0, 0), 1)
- else
- local cam=workspace.CurrentCamera
- local seat=vehicle:FindFirstChild("VehicleSeat")
- local angv=seat:FindFirstChild("angv")
- local vel=seat:FindFirstChild("vel")
- local gyro=seat:FindFirstChild("gy")
- local variables=vehicle:FindFirstChild("Variables")
- local speed=variables.Speed
- --Control
- if seat.Steer~=0 then
- variables.turnSpeed.Value=maxTurn*seat.Steer
- else
- variables.turnSpeed.Value=0
- end
- if seat.Throttle==1 then
- speed.Value=topSpeed+boospeed
- UpdateAnims(player.Character, "Moving")
- UpdateHoverboard(player,vehicle,canboost)
- elseif seat.Throttle==-1 then
- speed.Value=-topSpeed/4-boospeed
- UpdateAnims(player.Character, "Idle")
- UpdateHoverboard(player,vehicle,canboost)
- else
- speed.Value=0
- UpdateAnims(player.Character, "Idle")
- UpdateHoverboard(player,vehicle,canboost)
- end
- --Update
- local idle=seat.Idle
- if not idle.IsPlaying then idle:Play() end
- idle.Pitch=.3+(vel.velocity.Magnitude/topSpeed)
- local lv=seat.CFrame.lookVector
- local roll=(-angv.angularvelocity.y/maxTurn)*((vel.velocity.Magnitude/topSpeed)*.2+.2)
- vel.velocity=vel.velocity:Lerp(lv*variables.Speed.Value,acceleration)
- if seat.Orientation.X > 3 then
- angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(-3,-variables.turnSpeed.Value/1.5,0),handling)
- elseif seat.Orientation.X < -3 then
- angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(3,-variables.turnSpeed.Value/1.5,0),handling)
- else
- angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(0,-variables.turnSpeed.Value/1.5,0),handling)
- end
- gyro.cframe=CFrame.fromAxisAngle(lv,roll)
- if boospeed<=0 then boospeed=0 else boospeed=boospeed-1 end
- if zoomin==false then cam.FieldOfView=(70-cam.FieldOfView)*.05+cam.FieldOfView end
- cam.CameraType="Track"
- if canboost == true and debounce==false then boost(50,vel,seat,cam, player,vehicle,canboost) end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement