Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- Debris = game:GetService("Debris")
- DisplayModel = Tool:FindFirstChild("DisplayModel")
- if DisplayModel then
- DisplayModel:Destroy()
- end
- Assets = require(Tool:WaitForChild("Assets"))
- Data = Assets.Data
- BaseUrl = Assets.BaseUrl
- BasePart = Instance.new("Part")
- BasePart.Material = Enum.Material.Plastic
- BasePart.Shape = Enum.PartType.Block
- BasePart.TopSurface = Enum.SurfaceType.Smooth
- BasePart.BottomSurface = Enum.SurfaceType.Smooth
- BasePart.FormFactor = Enum.FormFactor.Custom
- BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
- BasePart.Anchored = false
- BasePart.CanCollide = true
- BasePart.Locked = true
- Animations = {
- Hold = {Animation = Tool:WaitForChild("Hold"), FadeTime = nil, Weight = nil, Speed = nil}
- }
- Sounds = {
- Honk = Handle:WaitForChild("Honk"),
- Engine = Handle:WaitForChild("Running")
- }
- Controls = {
- Forward = {Key = "w", ByteKey = 17, Mode = false},
- Backward = {Key = "s", ByteKey = 18, Mode = false},
- Left = {Key = "a", ByteKey = 20, Mode = false},
- Right = {Key = "d", ByteKey = 19, Mode = false}
- }
- Rate = (1 / 60)
- Gravity = 196.20
- PoseOffset = CFrame.new(0, 0.85, -1) * CFrame.Angles(0, 0, 0) --The offset your character is from the center of the vehicle.
- SpeedBoost = {
- Allowed = false,
- Active = false,
- Enabled = true,
- Duration = 10,
- ReloadTime = 30
- }
- Special = {
- Allowed = false,
- Enabled = true,
- Active = false,
- Duration = 0,
- ReloadTime = 60
- }
- Speed = {
- Acceleration = {
- Normal = 35,
- Boost = 35
- },
- Deceleration = {
- Normal = 30,
- Boost = 30
- },
- MovementSpeed = {
- Normal = {Min = 20, Max = 70},
- Boost = {Min = 20, Max = 70}
- },
- TurnSpeed = {
- Speed = {Min = 7.5, Max = 7.5},
- TurnAlpha = 0.30,
- AlphaDampening = 0.2
- },
- }
- MaxSpeed = { --Maximum speed which the vehicle can move and turn at.
- Movement = Speed.MovementSpeed.Normal,
- Turn = Speed.TurnSpeed.Speed,
- Acceleration = Speed.Acceleration.Normal,
- Deceleration = Speed.Deceleration.Normal
- }
- CurrentSpeed = { --The speed which the vehicle is moving and turning at.
- Movement = 0,
- Turn = 0
- }
- Honk = {
- Honking = false,
- LastHonk = 0,
- ReloadTime = 1
- }
- Jump = {
- Jumping = false,
- LastJump = 0,
- ReloadTime = 1.9,
- JumpForce = 30
- }
- TransparentParts = {}
- ToolEquipped = false
- ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
- ServerControl.Name = "ServerControl"
- ServerControl.Parent = Tool
- ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
- ClientControl.Name = "ClientControl"
- ClientControl.Parent = Tool
- Tool.Enabled = true
- function SetTransparency(PrimaryParent, Transparency)
- local Parts = {}
- local function SetParentTransparency(Parent)
- for i, v in pairs(Parent:GetChildren()) do
- if v ~= Tool then
- if v.Name ~= "HumanoidRootPart" then
- local ItemTransparent = false
- for ii, vv in pairs(TransparentParts) do
- if vv and vv.Part and vv.Part == v then
- ItemTransparent = true
- end
- end
- if not ItemTransparent then
- pcall(function()
- table.insert(Parts, {Part = v, Transparency = v.Transparency})
- v.Transparency = Transparency
- end)
- end
- end
- SetParentTransparency(v, Transparency)
- end
- end
- end
- SetParentTransparency(PrimaryParent)
- return Parts
- end
- function CheckTableForString(Table, String)
- for i, v in pairs(Table) do
- if string.find(string.lower(String), string.lower(v)) then
- return true
- end
- end
- return false
- end
- function CheckIntangible(Hit)
- local ProjectileNames = {"Water", "Arrow", "Projectile", "Effect", "Rail", "Laser", "Bullet"}
- if Hit and Hit.Parent then
- if CheckTableForString(ProjectileNames, Hit.Name) or Hit.Parent:FindFirstChild("Humanoid") then
- return true
- end
- end
- return false
- end
- function CastRay(StartPos, Vec, Length, Ignore, DelayIfHit)
- local Ignore = ((type(Ignore) == "table" and Ignore) or {Ignore})
- local RayHit, RayPos, RayNormal = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(StartPos, Vec * Length), Ignore)
- if RayHit and CheckIntangible(RayHit) then
- if DelayIfHit then
- wait()
- end
- RayHit, RayPos, RayNormal = CastRay((RayPos + (Vec * 0.01)), Vec, (Length - ((StartPos - RayPos).magnitude)), Ignore, DelayIfHit)
- end
- return RayHit, RayPos, RayNormal
- end
- function GetAllConnectedParts(Object)
- local Parts = {}
- local function GetConnectedParts(Object)
- for i, v in pairs(Object:GetConnectedParts()) do
- local Ignore = false
- for ii, vv in pairs(Parts) do
- if v == vv then
- Ignore = true
- end
- end
- if not Ignore then
- table.insert(Parts, v)
- GetConnectedParts(v)
- end
- end
- end
- GetConnectedParts(Object)
- return Parts
- end
- function EnableFirstPersonView()
- if not CheckIfAlive() or not ToolEquipped then
- return
- end
- local Limbs = {}
- if Humanoid then
- if Humanoid.RigType == Enum.HumanoidRigType.R6 then
- Limbs = {"Left Arm", "Right Arm"}
- elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
- Limbs = {"LeftLowerArm", "LeftUpperArm", "LeftHand", "RightLowerArm", "RightUpperArm", "RightHand"}
- end
- end
- for i, v in pairs(Limbs) do
- local Limb = Character:FindFirstChild(v)
- if Limb:IsA("BasePart") then
- Spawn(function()
- InvokeClient("SetLocalTransparencyModifier", {Object = Limb, Transparency = 0, AutoUpdate = false})
- end)
- end
- end
- end
- function GetLookVectorAngle(Direction)
- local Angle = math.acos(Direction:Dot(Vector3.new(1, 0, 0)))
- local Modifier = math.acos(Direction:Dot(Vector3.new(0, 0, -1)))
- return (Angle * (Modifier > (math.pi / 2) and -1 or 1))
- end
- function GetCFrameAngle(CFrame)
- local Vector1 = CFrame:vectorToWorldSpace(Vector3.FromNormalId(Enum.NormalId.Top))
- local Vector2 = Vector3.new(0, 1, 0)
- local Angle = math.acos(Vector1:Dot(Vector2))
- return Angle
- end
- function ThrustUpdater()
- for i, v in pairs(CurrentSpeed) do
- CurrentSpeed[i] = 0
- end
- for i, v in pairs(Controls) do
- Controls[i].Mode = false
- end
- while ToolEquipped and Body and Body.Parent and CheckIfAlive() and RotationForce and RotationForce.Parent and ThrustForce and ThrustForce.Parent and TurnGyro and TurnGyro.Parent do
- RotationForce.angularvelocity = Vector3.new(0, CurrentSpeed.Turn, 0)
- if math.abs(CurrentSpeed.Turn) > Speed.TurnSpeed.AlphaDampening then
- CurrentSpeed.Turn = (CurrentSpeed.Turn - (Speed.TurnSpeed.AlphaDampening * (math.abs(CurrentSpeed.Turn) / CurrentSpeed.Turn)))
- else
- CurrentSpeed.Turn = 0
- end
- if not Controls.Forward.Mode or Controls.Backward.Mode then --Slow down if not controlling.
- CurrentSpeed.Movement = (CurrentSpeed.Movement * 0.99)
- end
- local MySpeed = Vector3.new(Body.Velocity.X, 0, Body.Velocity.Z).magnitude
- local VelocityDifference = math.abs((MySpeed - (ThrustForce.velocity.magnitude)))
- if MySpeed > 3 and ThrustForce.velocity.magnitude > 3 and VelocityDifference > (0.7 * ThrustForce.velocity.magnitude) then
- CurrentSpeed.Movement = (CurrentSpeed.Movement * 0.9)
- end
- if Controls.Forward.Mode then --Handle acceleration
- CurrentSpeed.Movement = math.min(MaxSpeed.Movement.Max, (CurrentSpeed.Movement + (MaxSpeed.Acceleration * Rate)))
- end
- if Controls.Backward.Mode then --Handle deceleration, if speed is more than 0, decrease quicker.
- CurrentSpeed.Movement = math.max(-MaxSpeed.Movement.Min, (CurrentSpeed.Movement - (MaxSpeed.Deceleration * ((CurrentSpeed.Movement > 0 and 2.8) or 1) * Rate)))
- end
- if (Controls.Forward.Mode or Controls.Backward.Mode) or CurrentSpeed.Movement >= (MaxSpeed.Movement.Max * 0.35) then
- if Controls.Left.Mode then --Handle left turn speed
- CurrentSpeed.Turn = math.min(Speed.TurnSpeed.Speed.Max, (CurrentSpeed.Turn + (Speed.TurnSpeed.TurnAlpha)))
- end
- if Controls.Right.Mode then --Handle right turn speed
- CurrentSpeed.Turn = math.max(-Speed.TurnSpeed.Speed.Min, (CurrentSpeed.Turn - (Speed.TurnSpeed.TurnAlpha)))
- end
- end
- local Direction = Torso.CFrame.lookVector
- Direction = Vector3.new(Direction.x, 0, Direction.z).unit
- local Velocity = (Direction * CurrentSpeed.Movement) --The thrust force which you move.
- ThrustForce.velocity = Vector3.new(Velocity.X, ThrustForce.velocity.Y, Velocity.Z)
- local LeanAmount = (-CurrentSpeed.Turn * (math.pi / 6) / 4) --Amount your character leans over.
- local XZAngle = math.atan2(Torso.CFrame.lookVector.z, 0, Torso.CFrame.lookVector.x) --Handle rotation
- --TurnGyro.cframe = CFrame.Angles((LeanAmount * Direction.X), 0, (LeanAmount * Direction.Z))
- local RayPositions = {
- (Torso.CFrame * CFrame.new(0, 0, 0)),
- (Torso.CFrame * CFrame.new(0, 0, -((Body.Size.Z / 2) * 1))),
- (Torso.CFrame * CFrame.new(0, 0, ((Body.Size.Z / 2) * 1))),
- }
- local HighestPoint = {RayHit = nil, RayPos = nil, RayNormal = nil}
- for i, v in pairs(RayPositions) do
- local RayHit, RayPos, RayNormal = CastRay(v.p, Vector3.new(0, -1, 0), (Body.Size.Y * 2), {Character}, false)
- if RayHit and (not HighestPoint.RayPos or RayPos.Y > HighestPoint.RayPos.Y) then
- HighestPoint = {RayHit = RayHit, RayPos = RayPos, RayNormal = RayNormal}
- end
- end
- local AngleX, AngleY, AngleZ = Body.CFrame:toEulerAnglesXYZ()
- local Direction = ((HighestPoint.RayHit and (CFrame.new(HighestPoint.RayPos, (CFrame.new(HighestPoint.RayPos) + HighestPoint.RayNormal * 2).p) * CFrame.Angles((math.pi / 2), AngleY, math.pi))) or nil)
- TurnGyro.cframe = (((HighestPoint.RayHit and Direction and GetCFrameAngle(Direction) < (math.pi / 1.25)) and Direction) or CFrame.new(0, 0, 0))
- --Wheel animation
- local DesiredAngle = (999999999 * (-CurrentSpeed.Movement / math.abs(CurrentSpeed.Movement)))
- local MaxVelocity = (CurrentSpeed.Movement / 250)
- for i, v in pairs({FrontLeftMotor, FrontRightMotor, BackLeftMotor, BackRightMotor}) do
- if v and v.Parent then
- v.DesiredAngle = DesiredAngle
- v.MaxVelocity = MaxVelocity
- end
- end
- --Smoke exhaust from vehicle running.
- for i, v in pairs(ExhaustSmoke) do
- if v and v.Parent then
- v.Opacity = ((math.min(math.abs(CurrentSpeed.Movement), 10) / 10) * 0.5)
- end
- end
- --Engine running sound which pitch changes while in motion.
- Sounds.Engine.Pitch = (0.75 + (math.abs(CurrentSpeed.Movement / MaxSpeed.Movement.Max) * 1))
- wait(Rate)
- end
- end
- function SpawnVehicle()
- Handle.Transparency = 1
- Spawn(function()
- InvokeClient("PlaySound", Sounds.Engine)
- InvokeClient("PlayAnimation", Animations.Hold)
- end)
- Humanoid.AutoRotate = false
- Humanoid.PlatformStand = true
- Humanoid.CameraOffset = Vector3.new(0, 0, 0)
- local VehicleData = Assets.CreateVehicle()
- Body = VehicleData.Vehicle
- local ParticleTable = VehicleData.Tables
- FrontLeftMotor = Body.FrontLeftMotor
- FrontRightMotor = Body.FrontRightMotor
- BackLeftMotor = Body.BackLeftMotor
- BackRightMotor = Body.BackRightMotor
- ExhaustSmoke = ParticleTable.ExhaustSmoke
- Lights = ParticleTable.Lights
- Sparkles = ParticleTable.Sparkles
- if SpeedBoost.Active then
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = true
- end
- end
- end
- local TorsoWeld = Instance.new("Weld")
- TorsoWeld.C0 = PoseOffset
- TorsoWeld.Part0 = Torso
- TorsoWeld.Part1 = Body
- TorsoWeld.Parent = Body
- Body.CanCollide = true
- local BaseTransparency = 1
- TransparentParts = SetTransparency(Character, BaseTransparency)
- ItemAdded = Character.ChildAdded:connect(function(Child)
- for i, v in pairs(SetTransparency(Child, BaseTransparency)) do
- table.insert(TransparentParts, v)
- end
- end)
- ItemRemoved = Character.ChildRemoved:connect(function(Child)
- for i, v in pairs(Child:GetChildren()) do
- for ii, vv in pairs(TransparentParts) do
- if vv.Part == v then
- vv.Part.Transparency = vv.Transparency
- table.remove(TransparentParts, ii)
- end
- end
- end
- end)
- RotationForce = Instance.new("BodyAngularVelocity")
- RotationForce.maxTorque = Vector3.new(0, math.huge, 0)
- RotationForce.angularvelocity = Vector3.new(0, 0, 0)
- RotationForce.Parent = Torso
- ThrustForce = Instance.new("BodyVelocity")
- ThrustForce.maxForce = Vector3.new(math.huge, 0, math.huge)
- ThrustForce.velocity = Vector3.new(0, 0, 0)
- ThrustForce.P = 100
- ThrustForce.Parent = Torso
- TurnGyro = Instance.new("BodyGyro")
- TurnGyro.maxTorque = Vector3.new(math.huge, 0, math.huge)
- TurnGyro.P = 300
- TurnGyro.D = 100
- TurnGyro.Parent = Torso
- local RayHit, RayPos, RayNormal = CastRay(Torso.Position, Vector3.new(0, -1, 0), (Torso.Size.Y * 2.5), {Character}, false)
- if RayHit then
- Torso.CFrame = Torso.CFrame + Vector3.new(0, ((Character:GetModelSize().Y / 2) + 1.5), 0)
- end
- Body.CFrame = Torso.CFrame
- Body.Parent = Tool
- Spawn(ThrustUpdater)
- end
- function FreezePlayer()
- if CheckIfAlive() then
- local FreezePart = BasePart:Clone()
- FreezePart.Name = "FreezePart"
- FreezePart.Transparency = 1
- FreezePart.Anchored = true
- FreezePart.CanCollide = false
- local FreezeWeld = Instance.new("Weld")
- FreezeWeld.Part0 = Torso
- FreezeWeld.Part1 = FreezePart
- FreezeWeld.Parent = FreezePart
- Debris:AddItem(FreezePart, 0.125)
- FreezePart.Parent = Character
- Torso.Velocity = Vector3.new(0, -25, 0)
- Torso.RotVelocity = Vector3.new(0, 0, 0)
- end
- end
- function CleanUp()
- Handle.Velocity = Vector3.new(0, 0, 0)
- Handle.RotVelocity = Vector3.new(0, 0, 0)
- for i, v in pairs(TransparentParts) do
- if v and v.Part and v.Part.Parent then
- v.Part.Transparency = v.Transparency
- end
- end
- TransparentParts = {}
- for i, v in pairs({ItemAdded, ItemRemoved}) do
- if v then
- v:disconnect()
- end
- end
- for i, v in pairs({Body, RotationForce, ThrustForce, TurnGyro}) do
- if v and v.Parent then
- v:Destroy()
- end
- end
- for i, v in pairs(Tool:GetChildren()) do
- if v:IsA("BasePart") and v ~= Handle then
- v:Destroy()
- end
- end
- end
- function CheckIfAlive()
- 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)
- end
- function Equipped(Mouse)
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
- if not CheckIfAlive() then
- return
- end
- Spawn(CleanUp)
- --Spawn(EnableFirstPersonView)
- Spawn(SpawnVehicle)
- ToolEquipped = true
- end
- function Unequipped()
- Spawn(CleanUp)
- Spawn(FreezePlayer)
- for i, v in pairs(Sounds) do
- v:Stop()
- Spawn(function()
- InvokeClient("StopSound", v)
- end)
- end
- if CheckIfAlive() then
- Humanoid.CameraOffset = Vector3.new(0, 0, 0)
- Humanoid.AutoRotate = true
- Humanoid.PlatformStand = false
- local RayHit, RayPos, RayNormal = CastRay(Torso.Position, Vector3.new(0, -1, 0), (Torso.Size.Y * 2), {Character}, false)
- if RayHit then
- Torso.CFrame = Torso.CFrame + Vector3.new(0, ((Character:GetModelSize().Y / 2) + 1.5), 0)
- end
- end
- Handle.Transparency = 0
- ToolEquipped = false
- end
- function OnServerInvoke(player, mode, value)
- if player == Player and ToolEquipped and value and CheckIfAlive() then
- if mode == "KeyPress" then
- local Down = value.Down
- local Key = value.Key
- local ByteKey = string.byte(Key)
- for i, v in pairs(Controls) do
- if Key == v.Key or ByteKey == v.ByteKey then
- Controls[i].Mode = Down
- end
- end
- if Key == " " and Down then --Jump controller
- if math.abs(tick() - Jump.LastJump) > Jump.ReloadTime and not Jump.Jumping and ThrustForce and ThrustForce.Parent then
- Jump.Jumping = true
- local Parts = GetAllConnectedParts(Body)
- local Mass = 0
- for i, v in pairs(Parts) do
- Mass = (Mass + v:GetMass())
- end
- ThrustForce.maxForce = Vector3.new(ThrustForce.maxForce.X, ((Mass * Gravity) * 100), ThrustForce.maxForce.Z)
- ThrustForce.velocity = (Vector3.new(0, 1, 0) * Jump.JumpForce) + Vector3.new(ThrustForce.velocity.X, 0, ThrustForce.velocity.Z)
- wait(0.1)
- ThrustForce.maxForce = Vector3.new(ThrustForce.maxForce.X, 0, ThrustForce.maxForce.Z)
- ThrustForce.velocity = Vector3.new(ThrustForce.velocity.X, 0, ThrustForce.velocity.Z)
- Jump.LastJump = tick()
- Jump.Jumping = false
- end
- elseif Key == "x" and Down then --Toggle light(s) on/off.
- for i, v in pairs(Lights) do
- if v and v.Parent then
- v.Enabled = not v.Enabled
- end
- end
- elseif Key == "h" and Down then --Play honk sound.
- local Sound = Sounds.Honk
- if (tick() - Honk.LastHonk) >= (Sound.TimeLength + Honk.ReloadTime) and not Honk.Honking then
- Honk.Honking = true
- local TempSound = Sound:Clone()
- Debris:AddItem(TempSound, Sound.TimeLength)
- TempSound.Parent = Body
- TempSound:Play()
- Honk.LastHonk = tick()
- Honk.Honking = false
- end
- elseif Key == "q" and Down then --Activate special.
- if not Special.Allowed or not Special.Enabled or Special.Active then
- return
- end
- Special.Enabled = false
- Special.Active = true
- wait(Special.Duration)
- Special.Active = false
- wait(Special.ReloadTime)
- Special.Enabled = true
- elseif ByteKey == 48 and Down then --Activate speed boost.
- if not SpeedBoost.Allowed or not SpeedBoost.Enabled or SpeedBoost.Active then
- return
- end
- SpeedBoost.Enabled = false
- SpeedBoost.Active = true
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = true
- end
- end
- MaxSpeed.Acceleration = Speed.Acceleration.Boost
- MaxSpeed.Deceleration = Speed.Deceleration.Boost
- MaxSpeed.Movement = Speed.MovementSpeed.Boost
- wait(SpeedBoost.Duration)
- MaxSpeed.Acceleration = Speed.Acceleration.Normal
- MaxSpeed.Deceleration = Speed.Deceleration.Normal
- MaxSpeed.Movement = Speed.MovementSpeed.Normal
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = false
- end
- end
- SpeedBoost.Active = false
- wait(SpeedBoost.ReloadTime)
- SpeedBoost.Enabled = true
- end
- end
- end
- end
- function InvokeClient(Mode, Value)
- local ClientReturn = nil
- pcall(function()
- ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
- end)
- return ClientReturn
- end
- Spawn(CleanUp)
- Tool.Changed:connect(function(Property)
- if Property == "Parent" and Tool.Parent then
- Handle.Transparency = (((not Tool.Parent:IsA("Backpack") and not Players:GetPlayerFromCharacter(Tool.Parent)) and 0) or 1)
- end
- end)
- ServerControl.OnServerInvoke = OnServerInvoke
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Animation1 = Instance.new("Animation")
- Part2 = Instance.new("Part")
- Sound3 = Instance.new("Sound")
- Sound4 = Instance.new("Sound")
- SpecialMesh5 = Instance.new("SpecialMesh")
- Script6 = Instance.new("Script")
- LocalScript7 = Instance.new("LocalScript")
- LocalScript8 = Instance.new("LocalScript")
- ModuleScript9 = Instance.new("ModuleScript")
- RemoteFunction10 = Instance.new("RemoteFunction")
- RemoteFunction11 = Instance.new("RemoteFunction")
- Tool0.Name = "Corolla"
- Tool0.Parent = mas
- Tool0.TextureId = "rbxassetid://488158554"
- Tool0.Grip = CFrame.new(-2.75, 2, -0.75, 1, 3.05180438e-05, -3.05171125e-05, -3.05171125e-05, 1, 3.05180438e-05, 3.05180438e-05, -3.05171125e-05, 1)
- Tool0.GripForward = Vector3.new(3.05171125e-05, -3.05180438e-05, -1)
- Tool0.GripPos = Vector3.new(-2.75, 2, -0.75)
- Tool0.GripRight = Vector3.new(1, -3.05171125e-05, 3.05180438e-05)
- Tool0.GripUp = Vector3.new(3.05180438e-05, 1, -3.05171125e-05)
- Animation1.Name = "Hold"
- Animation1.Parent = Tool0
- Animation1.AnimationId = "http://www.roblox.com/asset/?id=264034706"
- Part2.Name = "Handle"
- Part2.Parent = Tool0
- Part2.CFrame = CFrame.new(-235.249954, 3.00001192, 49, 1, 4.74034932e-05, -1.24238431e-06, -4.74034969e-05, 0.99999994, -2.08965503e-08, 1.24424696e-06, 2.09547579e-08, 0.99999994)
- Part2.Position = Vector3.new(-235.249954, 3.00001192, 49)
- Part2.Size = Vector3.new(0.5, 2, 4)
- Part2.BottomSurface = Enum.SurfaceType.Smooth
- Part2.TopSurface = Enum.SurfaceType.Smooth
- Part2.FormFactor = Enum.FormFactor.Custom
- Part2.formFactor = Enum.FormFactor.Custom
- Sound3.Name = "Running"
- Sound3.Parent = Part2
- Sound3.Looped = true
- Sound3.EmitterSize = 0
- Sound3.MinDistance = 0
- Sound3.Pitch = 0.82130032777786
- Sound3.PlaybackSpeed = 0.82130032777786
- Sound3.SoundId = "http://www.roblox.com/asset/?id=247976926"
- Sound4.Name = "Honk"
- Sound4.Parent = Part2
- Sound4.EmitterSize = 0
- Sound4.MinDistance = 0
- Sound4.Pitch = 1.1000000238419
- Sound4.PlaybackSpeed = 1.1000000238419
- Sound4.SoundId = "http://www.roblox.com/asset/?id=248933537"
- Sound4.Volume = 0.34999999403954
- SpecialMesh5.Parent = Part2
- SpecialMesh5.MeshId = "rbxassetid://488158450"
- SpecialMesh5.Scale = Vector3.new(0.0700000003, 0.0700000003, 0.0700000003)
- SpecialMesh5.TextureId = "rbxassetid://488158554"
- SpecialMesh5.MeshType = Enum.MeshType.FileMesh
- Script6.Parent = Tool0
- table.insert(cors,sandbox(Script6,function()
- --Made by Luckymaxer
- --Updated for R15 avatar by StarWars
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- Debris = game:GetService("Debris")
- DisplayModel = Tool:FindFirstChild("DisplayModel")
- if DisplayModel then
- DisplayModel:Destroy()
- end
- Assets = require(Tool:WaitForChild("Assets"))
- Data = Assets.Data
- BaseUrl = Assets.BaseUrl
- BasePart = Instance.new("Part")
- BasePart.Material = Enum.Material.Plastic
- BasePart.Shape = Enum.PartType.Block
- BasePart.TopSurface = Enum.SurfaceType.Smooth
- BasePart.BottomSurface = Enum.SurfaceType.Smooth
- BasePart.FormFactor = Enum.FormFactor.Custom
- BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
- BasePart.Anchored = false
- BasePart.CanCollide = true
- BasePart.Locked = true
- Animations = {
- Hold = {Animation = Tool:WaitForChild("Hold"), FadeTime = nil, Weight = nil, Speed = nil}
- }
- Sounds = {
- Honk = Handle:WaitForChild("Honk"),
- Engine = Handle:WaitForChild("Running")
- }
- Controls = {
- Forward = {Key = "w", ByteKey = 17, Mode = false},
- Backward = {Key = "s", ByteKey = 18, Mode = false},
- Left = {Key = "a", ByteKey = 20, Mode = false},
- Right = {Key = "d", ByteKey = 19, Mode = false}
- }
- Rate = (1 / 60)
- Gravity = 196.20
- PoseOffset = CFrame.new(0, 0.85, -1) * CFrame.Angles(0, 0, 0) --The offset your character is from the center of the vehicle.
- SpeedBoost = {
- Allowed = false,
- Active = false,
- Enabled = true,
- Duration = 10,
- ReloadTime = 30
- }
- Special = {
- Allowed = false,
- Enabled = true,
- Active = false,
- Duration = 0,
- ReloadTime = 60
- }
- Speed = {
- Acceleration = {
- Normal = 35,
- Boost = 35
- },
- Deceleration = {
- Normal = 30,
- Boost = 30
- },
- MovementSpeed = {
- Normal = {Min = 20, Max = 70},
- Boost = {Min = 20, Max = 70}
- },
- TurnSpeed = {
- Speed = {Min = 7.5, Max = 7.5},
- TurnAlpha = 0.30,
- AlphaDampening = 0.2
- },
- }
- MaxSpeed = { --Maximum speed which the vehicle can move and turn at.
- Movement = Speed.MovementSpeed.Normal,
- Turn = Speed.TurnSpeed.Speed,
- Acceleration = Speed.Acceleration.Normal,
- Deceleration = Speed.Deceleration.Normal
- }
- CurrentSpeed = { --The speed which the vehicle is moving and turning at.
- Movement = 0,
- Turn = 0
- }
- Honk = {
- Honking = false,
- LastHonk = 0,
- ReloadTime = 1
- }
- Jump = {
- Jumping = false,
- LastJump = 0,
- ReloadTime = 1.9,
- JumpForce = 30
- }
- TransparentParts = {}
- ToolEquipped = false
- ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
- ServerControl.Name = "ServerControl"
- ServerControl.Parent = Tool
- ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
- ClientControl.Name = "ClientControl"
- ClientControl.Parent = Tool
- Tool.Enabled = true
- function SetTransparency(PrimaryParent, Transparency)
- local Parts = {}
- local function SetParentTransparency(Parent)
- for i, v in pairs(Parent:GetChildren()) do
- if v ~= Tool then
- if v.Name ~= "HumanoidRootPart" then
- local ItemTransparent = false
- for ii, vv in pairs(TransparentParts) do
- if vv and vv.Part and vv.Part == v then
- ItemTransparent = true
- end
- end
- if not ItemTransparent then
- pcall(function()
- table.insert(Parts, {Part = v, Transparency = v.Transparency})
- v.Transparency = Transparency
- end)
- end
- end
- SetParentTransparency(v, Transparency)
- end
- end
- end
- SetParentTransparency(PrimaryParent)
- return Parts
- end
- function CheckTableForString(Table, String)
- for i, v in pairs(Table) do
- if string.find(string.lower(String), string.lower(v)) then
- return true
- end
- end
- return false
- end
- function CheckIntangible(Hit)
- local ProjectileNames = {"Water", "Arrow", "Projectile", "Effect", "Rail", "Laser", "Bullet"}
- if Hit and Hit.Parent then
- if CheckTableForString(ProjectileNames, Hit.Name) or Hit.Parent:FindFirstChild("Humanoid") then
- return true
- end
- end
- return false
- end
- function CastRay(StartPos, Vec, Length, Ignore, DelayIfHit)
- local Ignore = ((type(Ignore) == "table" and Ignore) or {Ignore})
- local RayHit, RayPos, RayNormal = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(StartPos, Vec * Length), Ignore)
- if RayHit and CheckIntangible(RayHit) then
- if DelayIfHit then
- wait()
- end
- RayHit, RayPos, RayNormal = CastRay((RayPos + (Vec * 0.01)), Vec, (Length - ((StartPos - RayPos).magnitude)), Ignore, DelayIfHit)
- end
- return RayHit, RayPos, RayNormal
- end
- function GetAllConnectedParts(Object)
- local Parts = {}
- local function GetConnectedParts(Object)
- for i, v in pairs(Object:GetConnectedParts()) do
- local Ignore = false
- for ii, vv in pairs(Parts) do
- if v == vv then
- Ignore = true
- end
- end
- if not Ignore then
- table.insert(Parts, v)
- GetConnectedParts(v)
- end
- end
- end
- GetConnectedParts(Object)
- return Parts
- end
- function EnableFirstPersonView()
- if not CheckIfAlive() or not ToolEquipped then
- return
- end
- local Limbs = {}
- if Humanoid then
- if Humanoid.RigType == Enum.HumanoidRigType.R6 then
- Limbs = {"Left Arm", "Right Arm"}
- elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
- Limbs = {"LeftLowerArm", "LeftUpperArm", "LeftHand", "RightLowerArm", "RightUpperArm", "RightHand"}
- end
- end
- for i, v in pairs(Limbs) do
- local Limb = Character:FindFirstChild(v)
- if Limb:IsA("BasePart") then
- Spawn(function()
- InvokeClient("SetLocalTransparencyModifier", {Object = Limb, Transparency = 0, AutoUpdate = false})
- end)
- end
- end
- end
- function GetLookVectorAngle(Direction)
- local Angle = math.acos(Direction:Dot(Vector3.new(1, 0, 0)))
- local Modifier = math.acos(Direction:Dot(Vector3.new(0, 0, -1)))
- return (Angle * (Modifier > (math.pi / 2) and -1 or 1))
- end
- function GetCFrameAngle(CFrame)
- local Vector1 = CFrame:vectorToWorldSpace(Vector3.FromNormalId(Enum.NormalId.Top))
- local Vector2 = Vector3.new(0, 1, 0)
- local Angle = math.acos(Vector1:Dot(Vector2))
- return Angle
- end
- function ThrustUpdater()
- for i, v in pairs(CurrentSpeed) do
- CurrentSpeed[i] = 0
- end
- for i, v in pairs(Controls) do
- Controls[i].Mode = false
- end
- while ToolEquipped and Body and Body.Parent and CheckIfAlive() and RotationForce and RotationForce.Parent and ThrustForce and ThrustForce.Parent and TurnGyro and TurnGyro.Parent do
- RotationForce.angularvelocity = Vector3.new(0, CurrentSpeed.Turn, 0)
- if math.abs(CurrentSpeed.Turn) > Speed.TurnSpeed.AlphaDampening then
- CurrentSpeed.Turn = (CurrentSpeed.Turn - (Speed.TurnSpeed.AlphaDampening * (math.abs(CurrentSpeed.Turn) / CurrentSpeed.Turn)))
- else
- CurrentSpeed.Turn = 0
- end
- if not Controls.Forward.Mode or Controls.Backward.Mode then --Slow down if not controlling.
- CurrentSpeed.Movement = (CurrentSpeed.Movement * 0.99)
- end
- local MySpeed = Vector3.new(Body.Velocity.X, 0, Body.Velocity.Z).magnitude
- local VelocityDifference = math.abs((MySpeed - (ThrustForce.velocity.magnitude)))
- if MySpeed > 3 and ThrustForce.velocity.magnitude > 3 and VelocityDifference > (0.7 * ThrustForce.velocity.magnitude) then
- CurrentSpeed.Movement = (CurrentSpeed.Movement * 0.9)
- end
- if Controls.Forward.Mode then --Handle acceleration
- CurrentSpeed.Movement = math.min(MaxSpeed.Movement.Max, (CurrentSpeed.Movement + (MaxSpeed.Acceleration * Rate)))
- end
- if Controls.Backward.Mode then --Handle deceleration, if speed is more than 0, decrease quicker.
- CurrentSpeed.Movement = math.max(-MaxSpeed.Movement.Min, (CurrentSpeed.Movement - (MaxSpeed.Deceleration * ((CurrentSpeed.Movement > 0 and 2.8) or 1) * Rate)))
- end
- if (Controls.Forward.Mode or Controls.Backward.Mode) or CurrentSpeed.Movement >= (MaxSpeed.Movement.Max * 0.35) then
- if Controls.Left.Mode then --Handle left turn speed
- CurrentSpeed.Turn = math.min(Speed.TurnSpeed.Speed.Max, (CurrentSpeed.Turn + (Speed.TurnSpeed.TurnAlpha)))
- end
- if Controls.Right.Mode then --Handle right turn speed
- CurrentSpeed.Turn = math.max(-Speed.TurnSpeed.Speed.Min, (CurrentSpeed.Turn - (Speed.TurnSpeed.TurnAlpha)))
- end
- end
- local Direction = Torso.CFrame.lookVector
- Direction = Vector3.new(Direction.x, 0, Direction.z).unit
- local Velocity = (Direction * CurrentSpeed.Movement) --The thrust force which you move.
- ThrustForce.velocity = Vector3.new(Velocity.X, ThrustForce.velocity.Y, Velocity.Z)
- local LeanAmount = (-CurrentSpeed.Turn * (math.pi / 6) / 4) --Amount your character leans over.
- local XZAngle = math.atan2(Torso.CFrame.lookVector.z, 0, Torso.CFrame.lookVector.x) --Handle rotation
- --TurnGyro.cframe = CFrame.Angles((LeanAmount * Direction.X), 0, (LeanAmount * Direction.Z))
- local RayPositions = {
- (Torso.CFrame * CFrame.new(0, 0, 0)),
- (Torso.CFrame * CFrame.new(0, 0, -((Body.Size.Z / 2) * 1))),
- (Torso.CFrame * CFrame.new(0, 0, ((Body.Size.Z / 2) * 1))),
- }
- local HighestPoint = {RayHit = nil, RayPos = nil, RayNormal = nil}
- for i, v in pairs(RayPositions) do
- local RayHit, RayPos, RayNormal = CastRay(v.p, Vector3.new(0, -1, 0), (Body.Size.Y * 2), {Character}, false)
- if RayHit and (not HighestPoint.RayPos or RayPos.Y > HighestPoint.RayPos.Y) then
- HighestPoint = {RayHit = RayHit, RayPos = RayPos, RayNormal = RayNormal}
- end
- end
- local AngleX, AngleY, AngleZ = Body.CFrame:toEulerAnglesXYZ()
- local Direction = ((HighestPoint.RayHit and (CFrame.new(HighestPoint.RayPos, (CFrame.new(HighestPoint.RayPos) + HighestPoint.RayNormal * 2).p) * CFrame.Angles((math.pi / 2), AngleY, math.pi))) or nil)
- TurnGyro.cframe = (((HighestPoint.RayHit and Direction and GetCFrameAngle(Direction) < (math.pi / 1.25)) and Direction) or CFrame.new(0, 0, 0))
- --Wheel animation
- local DesiredAngle = (999999999 * (-CurrentSpeed.Movement / math.abs(CurrentSpeed.Movement)))
- local MaxVelocity = (CurrentSpeed.Movement / 250)
- for i, v in pairs({FrontLeftMotor, FrontRightMotor, BackLeftMotor, BackRightMotor}) do
- if v and v.Parent then
- v.DesiredAngle = DesiredAngle
- v.MaxVelocity = MaxVelocity
- end
- end
- --Smoke exhaust from vehicle running.
- for i, v in pairs(ExhaustSmoke) do
- if v and v.Parent then
- v.Opacity = ((math.min(math.abs(CurrentSpeed.Movement), 10) / 10) * 0.5)
- end
- end
- --Engine running sound which pitch changes while in motion.
- Sounds.Engine.Pitch = (0.75 + (math.abs(CurrentSpeed.Movement / MaxSpeed.Movement.Max) * 1))
- wait(Rate)
- end
- end
- function SpawnVehicle()
- Handle.Transparency = 1
- Spawn(function()
- InvokeClient("PlaySound", Sounds.Engine)
- InvokeClient("PlayAnimation", Animations.Hold)
- end)
- Humanoid.AutoRotate = false
- Humanoid.PlatformStand = true
- Humanoid.CameraOffset = Vector3.new(0, 0, 0)
- local VehicleData = Assets.CreateVehicle()
- Body = VehicleData.Vehicle
- local ParticleTable = VehicleData.Tables
- FrontLeftMotor = Body.FrontLeftMotor
- FrontRightMotor = Body.FrontRightMotor
- BackLeftMotor = Body.BackLeftMotor
- BackRightMotor = Body.BackRightMotor
- ExhaustSmoke = ParticleTable.ExhaustSmoke
- Lights = ParticleTable.Lights
- Sparkles = ParticleTable.Sparkles
- if SpeedBoost.Active then
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = true
- end
- end
- end
- local TorsoWeld = Instance.new("Weld")
- TorsoWeld.C0 = PoseOffset
- TorsoWeld.Part0 = Torso
- TorsoWeld.Part1 = Body
- TorsoWeld.Parent = Body
- Body.CanCollide = true
- local BaseTransparency = 1
- TransparentParts = SetTransparency(Character, BaseTransparency)
- ItemAdded = Character.ChildAdded:connect(function(Child)
- for i, v in pairs(SetTransparency(Child, BaseTransparency)) do
- table.insert(TransparentParts, v)
- end
- end)
- ItemRemoved = Character.ChildRemoved:connect(function(Child)
- for i, v in pairs(Child:GetChildren()) do
- for ii, vv in pairs(TransparentParts) do
- if vv.Part == v then
- vv.Part.Transparency = vv.Transparency
- table.remove(TransparentParts, ii)
- end
- end
- end
- end)
- RotationForce = Instance.new("BodyAngularVelocity")
- RotationForce.maxTorque = Vector3.new(0, math.huge, 0)
- RotationForce.angularvelocity = Vector3.new(0, 0, 0)
- RotationForce.Parent = Torso
- ThrustForce = Instance.new("BodyVelocity")
- ThrustForce.maxForce = Vector3.new(math.huge, 0, math.huge)
- ThrustForce.velocity = Vector3.new(0, 0, 0)
- ThrustForce.P = 100
- ThrustForce.Parent = Torso
- TurnGyro = Instance.new("BodyGyro")
- TurnGyro.maxTorque = Vector3.new(math.huge, 0, math.huge)
- TurnGyro.P = 300
- TurnGyro.D = 100
- TurnGyro.Parent = Torso
- local RayHit, RayPos, RayNormal = CastRay(Torso.Position, Vector3.new(0, -1, 0), (Torso.Size.Y * 2.5), {Character}, false)
- if RayHit then
- Torso.CFrame = Torso.CFrame + Vector3.new(0, ((Character:GetModelSize().Y / 2) + 1.5), 0)
- end
- Body.CFrame = Torso.CFrame
- Body.Parent = Tool
- Spawn(ThrustUpdater)
- end
- function FreezePlayer()
- if CheckIfAlive() then
- local FreezePart = BasePart:Clone()
- FreezePart.Name = "FreezePart"
- FreezePart.Transparency = 1
- FreezePart.Anchored = true
- FreezePart.CanCollide = false
- local FreezeWeld = Instance.new("Weld")
- FreezeWeld.Part0 = Torso
- FreezeWeld.Part1 = FreezePart
- FreezeWeld.Parent = FreezePart
- Debris:AddItem(FreezePart, 0.125)
- FreezePart.Parent = Character
- Torso.Velocity = Vector3.new(0, -25, 0)
- Torso.RotVelocity = Vector3.new(0, 0, 0)
- end
- end
- function CleanUp()
- Handle.Velocity = Vector3.new(0, 0, 0)
- Handle.RotVelocity = Vector3.new(0, 0, 0)
- for i, v in pairs(TransparentParts) do
- if v and v.Part and v.Part.Parent then
- v.Part.Transparency = v.Transparency
- end
- end
- TransparentParts = {}
- for i, v in pairs({ItemAdded, ItemRemoved}) do
- if v then
- v:disconnect()
- end
- end
- for i, v in pairs({Body, RotationForce, ThrustForce, TurnGyro}) do
- if v and v.Parent then
- v:Destroy()
- end
- end
- for i, v in pairs(Tool:GetChildren()) do
- if v:IsA("BasePart") and v ~= Handle then
- v:Destroy()
- end
- end
- end
- function CheckIfAlive()
- 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)
- end
- function Equipped(Mouse)
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
- if not CheckIfAlive() then
- return
- end
- Spawn(CleanUp)
- --Spawn(EnableFirstPersonView)
- Spawn(SpawnVehicle)
- ToolEquipped = true
- end
- function Unequipped()
- Spawn(CleanUp)
- Spawn(FreezePlayer)
- for i, v in pairs(Sounds) do
- v:Stop()
- Spawn(function()
- InvokeClient("StopSound", v)
- end)
- end
- if CheckIfAlive() then
- Humanoid.CameraOffset = Vector3.new(0, 0, 0)
- Humanoid.AutoRotate = true
- Humanoid.PlatformStand = false
- local RayHit, RayPos, RayNormal = CastRay(Torso.Position, Vector3.new(0, -1, 0), (Torso.Size.Y * 2), {Character}, false)
- if RayHit then
- Torso.CFrame = Torso.CFrame + Vector3.new(0, ((Character:GetModelSize().Y / 2) + 1.5), 0)
- end
- end
- Handle.Transparency = 0
- ToolEquipped = false
- end
- function OnServerInvoke(player, mode, value)
- if player == Player and ToolEquipped and value and CheckIfAlive() then
- if mode == "KeyPress" then
- local Down = value.Down
- local Key = value.Key
- local ByteKey = string.byte(Key)
- for i, v in pairs(Controls) do
- if Key == v.Key or ByteKey == v.ByteKey then
- Controls[i].Mode = Down
- end
- end
- if Key == " " and Down then --Jump controller
- if math.abs(tick() - Jump.LastJump) > Jump.ReloadTime and not Jump.Jumping and ThrustForce and ThrustForce.Parent then
- Jump.Jumping = true
- local Parts = GetAllConnectedParts(Body)
- local Mass = 0
- for i, v in pairs(Parts) do
- Mass = (Mass + v:GetMass())
- end
- ThrustForce.maxForce = Vector3.new(ThrustForce.maxForce.X, ((Mass * Gravity) * 100), ThrustForce.maxForce.Z)
- ThrustForce.velocity = (Vector3.new(0, 1, 0) * Jump.JumpForce) + Vector3.new(ThrustForce.velocity.X, 0, ThrustForce.velocity.Z)
- wait(0.1)
- ThrustForce.maxForce = Vector3.new(ThrustForce.maxForce.X, 0, ThrustForce.maxForce.Z)
- ThrustForce.velocity = Vector3.new(ThrustForce.velocity.X, 0, ThrustForce.velocity.Z)
- Jump.LastJump = tick()
- Jump.Jumping = false
- end
- elseif Key == "x" and Down then --Toggle light(s) on/off.
- for i, v in pairs(Lights) do
- if v and v.Parent then
- v.Enabled = not v.Enabled
- end
- end
- elseif Key == "h" and Down then --Play honk sound.
- local Sound = Sounds.Honk
- if (tick() - Honk.LastHonk) >= (Sound.TimeLength + Honk.ReloadTime) and not Honk.Honking then
- Honk.Honking = true
- local TempSound = Sound:Clone()
- Debris:AddItem(TempSound, Sound.TimeLength)
- TempSound.Parent = Body
- TempSound:Play()
- Honk.LastHonk = tick()
- Honk.Honking = false
- end
- elseif Key == "q" and Down then --Activate special.
- if not Special.Allowed or not Special.Enabled or Special.Active then
- return
- end
- Special.Enabled = false
- Special.Active = true
- wait(Special.Duration)
- Special.Active = false
- wait(Special.ReloadTime)
- Special.Enabled = true
- elseif ByteKey == 48 and Down then --Activate speed boost.
- if not SpeedBoost.Allowed or not SpeedBoost.Enabled or SpeedBoost.Active then
- return
- end
- SpeedBoost.Enabled = false
- SpeedBoost.Active = true
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = true
- end
- end
- MaxSpeed.Acceleration = Speed.Acceleration.Boost
- MaxSpeed.Deceleration = Speed.Deceleration.Boost
- MaxSpeed.Movement = Speed.MovementSpeed.Boost
- wait(SpeedBoost.Duration)
- MaxSpeed.Acceleration = Speed.Acceleration.Normal
- MaxSpeed.Deceleration = Speed.Deceleration.Normal
- MaxSpeed.Movement = Speed.MovementSpeed.Normal
- for i, v in pairs(Sparkles) do
- if v and v.Parent then
- v.Enabled = false
- end
- end
- SpeedBoost.Active = false
- wait(SpeedBoost.ReloadTime)
- SpeedBoost.Enabled = true
- end
- end
- end
- end
- function InvokeClient(Mode, Value)
- local ClientReturn = nil
- pcall(function()
- ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
- end)
- return ClientReturn
- end
- Spawn(CleanUp)
- Tool.Changed:connect(function(Property)
- if Property == "Parent" and Tool.Parent then
- Handle.Transparency = (((not Tool.Parent:IsA("Backpack") and not Players:GetPlayerFromCharacter(Tool.Parent)) and 0) or 1)
- end
- end)
- ServerControl.OnServerInvoke = OnServerInvoke
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- end))
- LocalScript7.Name = "MouseIcon"
- LocalScript7.Parent = Tool0
- table.insert(cors,sandbox(LocalScript7,function()
- --Made by Luckymaxer
- Mouse_Icon = "rbxasset://textures/GunCursor.png"
- Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
- Tool = script.Parent
- Mouse = nil
- function UpdateIcon()
- if Mouse then
- Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
- end
- end
- function OnEquipped(ToolMouse)
- Mouse = ToolMouse
- UpdateIcon()
- end
- function OnChanged(Property)
- if Property == "Enabled" then
- UpdateIcon()
- end
- end
- Tool.Equipped:connect(OnEquipped)
- Tool.Changed:connect(OnChanged)
- end))
- LocalScript8.Parent = Tool0
- table.insert(cors,sandbox(LocalScript8,function()
- --Made by Luckymaxer
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- RunService = game:GetService("RunService")
- Camera = game:GetService("Workspace").CurrentCamera
- Animations = {}
- LocalObjects = {}
- ServerControl = Tool:WaitForChild("ServerControl")
- ClientControl = Tool:WaitForChild("ClientControl")
- ToolEquipped = false
- function SetAnimation(mode, value)
- if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
- for i, v in pairs(Animations) do
- if v.Animation == value.Animation then
- v.AnimationTrack:Stop()
- table.remove(Animations, i)
- end
- end
- local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
- table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack})
- AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
- elseif mode == "StopAnimation" and value then
- for i, v in pairs(Animations) do
- if v.Animation == value.Animation then
- v.AnimationTrack:Stop()
- table.remove(Animations, i)
- end
- end
- end
- end
- function DisableJump(Boolean)
- if PreventJump then
- PreventJump:disconnect()
- end
- if Boolean then
- PreventJump = Humanoid.Changed:connect(function(Property)
- if Property == "Jump" then
- Humanoid.Jump = false
- end
- end)
- end
- end
- function CheckIfAlive()
- return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Player and Player.Parent) and true) or false)
- end
- function Equipped(Mouse)
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- ToolEquipped = true
- if not CheckIfAlive() then
- return
- end
- PlayerMouse = Player:GetMouse()
- Mouse.Button1Down:connect(function()
- InvokeServer("MouseClick", {Down = true})
- end)
- Mouse.Button1Up:connect(function()
- InvokeServer("MouseClick", {Down = false})
- end)
- Mouse.KeyDown:connect(function(Key)
- InvokeServer("KeyPress", {Key = Key, Down = true})
- end)
- Mouse.KeyUp:connect(function(Key)
- InvokeServer("KeyPress", {Key = Key, Down = false})
- end)
- Mouse.Move:connect(function()
- InvokeServer("MouseMove", {Position = Mouse.Hit.p, Target = Mouse.Target})
- end)
- Humanoid:ChangeState(Enum.HumanoidStateType.None)
- end
- function Unequipped()
- ToolEquipped = false
- LocalObjects = {}
- for i, v in pairs(Animations) do
- if v and v.AnimationTrack then
- v.AnimationTrack:Stop()
- end
- end
- for i, v in pairs({PreventJump, ObjectLocalTransparencyModifier}) do
- if v then
- v:disconnect()
- end
- end
- Humanoid:ChangeState(Enum.HumanoidStateType.Freefall) --Prevent the ability to fly by constantly equipping and unequipping the tool.
- Animations = {}
- end
- function InvokeServer(mode, value)
- pcall(function()
- local ServerReturn = ServerControl:InvokeServer(mode, value)
- return ServerReturn
- end)
- end
- function OnClientInvoke(mode, value)
- if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
- SetAnimation("PlayAnimation", value)
- elseif mode == "StopAnimation" and value then
- SetAnimation("StopAnimation", value)
- elseif mode == "PlaySound" and value then
- value:Play()
- elseif mode == "StopSound" and value then
- value:Stop()
- elseif mode == "MousePosition" then
- return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
- elseif mode == "DisableJump" then
- DisableJump(value)
- elseif mode == "SetLocalTransparencyModifier" and value and ToolEquipped then
- pcall(function()
- local ObjectFound = false
- for i, v in pairs(LocalObjects) do
- if v == value then
- ObjectFound = true
- end
- end
- if not ObjectFound then
- table.insert(LocalObjects, value)
- if ObjectLocalTransparencyModifier then
- ObjectLocalTransparencyModifier:disconnect()
- end
- ObjectLocalTransparencyModifier = RunService.RenderStepped:connect(function()
- for i, v in pairs(LocalObjects) do
- if v.Object and v.Object.Parent then
- local CurrentTransparency = v.Object.LocalTransparencyModifier
- if ((not v.AutoUpdate and (CurrentTransparency == 1 or CurrentTransparency == 0)) or v.AutoUpdate) then
- v.Object.LocalTransparencyModifier = v.Transparency
- end
- else
- table.remove(LocalObjects, i)
- end
- end
- end)
- end
- end)
- end
- end
- ClientControl.OnClientInvoke = OnClientInvoke
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- end))
- ModuleScript9.Name = "Assets"
- ModuleScript9.Parent = Tool0
- table.insert(cors,sandbox(ModuleScript9,function()
- --Made by Luckymaxer
- BaseUrl = "http://www.roblox.com/asset/?id="
- RbxUtility = LoadLibrary("RbxUtility")
- Create = RbxUtility.Create
- BasePart = Create("Part"){
- Material = Enum.Material.Plastic,
- Shape = Enum.PartType.Block,
- TopSurface = Enum.SurfaceType.Smooth,
- BottomSurface = Enum.SurfaceType.Smooth,
- FormFactor = Enum.FormFactor.Custom,
- Size = Vector3.new(0.2, 0.2, 0.2),
- Anchored = false,
- CanCollide = true,
- Locked = true
- }
- MeshData = {
- Meshes = {
- Body = 488158450,
- Wheel = 0,
- },
- TextureId = 488158554,
- }
- function CreateVehicle()
- local ExhaustSmoke = {}
- local Lights = {}
- local Sparkles = {}
- local Body = BasePart:Clone()
- Body.Name = "Body"
- Body.Size = Vector3.new(6.25, 3.9, 12)
- local BodyMesh = Create("SpecialMesh"){
- MeshType = Enum.MeshType.FileMesh,
- MeshId = MeshData.Meshes.Body,
- TextureId = MeshData.TextureId,
- Scale = Vector3.new(0.07, 0.07, 0.07),
- VertexColor = Vector3.new(1, 1, 1),
- Offset = Vector3.new(0, 0.2, 0),
- Parent = Body
- }
- local BaseWheel = BasePart:Clone()
- BaseWheel.Size = Vector3.new(0.5, 1, 1)
- BaseWheel.CanCollide = false
- local WheelMesh = Create("SpecialMesh"){
- MeshType = Enum.MeshType.FileMesh,
- MeshId = MeshData.Meshes.Wheel,
- TextureId = MeshData.TextureId,
- Scale = Vector3.new(1.6, 1.6, 1.6),
- VertexColor = Vector3.new(1, 1, 1),
- Offset = Vector3.new(0, 0, 0),
- Parent = BaseWheel,
- }
- local BaseFrontWheel = BaseWheel:Clone()
- BaseFrontWheel.Name = "FrontWheel"
- local BaseBackWheel = BaseWheel:Clone()
- BaseBackWheel.Name = "BackWheel"
- local BaseSmokePart = BasePart:Clone()
- BaseSmokePart.Name = "SmokePart"
- BaseSmokePart.Transparency = 1
- BaseSmokePart.CanCollide = false
- local BaseExhaustSmoke = Create("Smoke"){
- Name = "ExhaustSmoke",
- Size = 0.1,
- RiseVelocity = 0.01,
- Color = Color3.new((127 / 255), (127 / 255), (127 / 255)),
- Enabled = true,
- Parent = BaseSmokePart,
- }
- local BaseLightPart = BasePart:Clone()
- BaseLightPart.Name = "LightPart"
- BaseLightPart.Transparency = 1
- BaseLightPart.CanCollide = false
- local Light = Create("SpotLight"){
- Name = "Light",
- Brightness = 5,
- Angle = 45,
- Color = Color3.new(255 / 255, 252 / 255, 153 / 255),
- Range = 30,
- Shadows = false,
- Enabled = false,
- Parent = BaseLightPart,
- }
- local FrontLeftWheel = BaseFrontWheel:Clone()
- FrontLeftWheel.Name = "FrontLeftWheel"
- FrontLeftWheel.Parent = Body
- local FrontLeftMotor = Create("Motor6D"){
- Name = "FrontLeftMotor",
- Part0 = Body,
- Part1 = FrontLeftWheel,
- C0 = CFrame.new(-2.25, -1.1, -3.25) * CFrame.Angles(0, (math.pi / 2), 0),
- C1 = CFrame.new(0, -0.1, 0) * CFrame.Angles(0, (math.pi / 2), 0),
- Parent = Body
- }
- local FrontRightWheel = BaseFrontWheel:Clone()
- FrontRightWheel.Name = "FrontRightWheel"
- FrontRightWheel.Parent = Body
- local FrontRightMotor = Create("Motor6D"){
- Name = "FrontRightMotor",
- Part0 = Body,
- Part1 = FrontRightWheel,
- C0 = CFrame.new(2.25, -1.1, -3.25) * CFrame.Angles(0, (math.pi / 2), 0),
- C1 = CFrame.new(0, -0.1, 0) * CFrame.Angles(0, -(math.pi / 2), 0),
- Parent = Body
- }
- local BackLeftWheel = BaseBackWheel:Clone()
- BackLeftWheel.Name = "BackLeftWheel"
- BackLeftWheel.Parent = Body
- local BackLeftMotor = Create("Motor6D"){
- Name = "BackLeftMotor",
- Part0 = Body,
- Part1 = BackLeftWheel,
- C0 = CFrame.new(-2.25, -1.1, 3.95) * CFrame.Angles(0, (math.pi / 2), 0),
- C1 = CFrame.new(0, -0.1, 0) * CFrame.Angles(0, (math.pi / 2), 0),
- Parent = Body
- }
- local BackRightWheel = BackLeftWheel:Clone()
- BackRightWheel.Name = "BackRightWheel"
- BackRightWheel.Parent = Body
- local BackRightMotor = Create("Motor6D"){
- Name = "BackRightMotor",
- Part0 = Body,
- Part1 = BackRightWheel,
- C0 = CFrame.new(2.25, -1.1, 3.95) * CFrame.Angles(0, (math.pi / 2), 0),
- C1 = CFrame.new(0, -0.1, 0) * CFrame.Angles(0, -(math.pi / 2), 0),
- Parent = Body
- }
- local HeadLight = BaseLightPart:Clone()
- HeadLight.Parent = Body
- table.insert(Lights, HeadLight.Light)
- for i, v in pairs(HeadLight:GetChildren()) do
- if v:IsA("Sparkles") then
- table.insert(Sparkles, v)
- end
- end
- local LightWeld = Create("Weld"){
- Part0 = Body,
- Part1 = HeadLight,
- C0 = CFrame.new(0, 0, -3) * CFrame.Angles(0, 0, 0),
- Parent = HeadLight
- }
- local ExhaustPipe = BaseSmokePart:Clone()
- ExhaustPipe.Name = "ExhaustPipe"
- ExhaustPipe.Parent = Body
- table.insert(ExhaustSmoke, ExhaustPipe.ExhaustSmoke)
- local SmokeWeld = Create("Weld"){
- C0 = CFrame.new(0, 0, -8.25) * CFrame.Angles(0, 0, 0),
- Part0 = ExhaustPipe,
- Part1 = Body,
- Parent = ExhaustPipe
- }
- local Tables = {
- ExhaustSmoke = ExhaustSmoke,
- Lights = Lights,
- Sparkles = Sparkles
- }
- return {
- Vehicle = Body,
- Tables = Tables
- }
- end
- for i, v in pairs(MeshData) do
- if type(v) == "table" then
- for ii, vv in pairs(v) do
- if type(vv) == "string" or type(vv) == "number" then
- MeshData[i][ii] = (BaseUrl .. tostring(vv))
- end
- end
- elseif type(v) == "string" or type(v) == "number" then
- MeshData[i] = (BaseUrl .. tostring(v))
- end
- end
- return {
- BaseUrl = BaseUrl,
- MeshData = MeshData,
- CreateVehicle = CreateVehicle
- }
- end))
- RemoteFunction10.Name = "ServerControl"
- RemoteFunction10.Parent = Tool0
- RemoteFunction11.Name = "ClientControl"
- RemoteFunction11.Parent = Tool0
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = workspace
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement