Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Version = "0.1"
- local UpdateDate = "20 March, 2018"
- local UpdateNote = "Cleaned up messy code. Fixes. Added sounds."
- print("v" .. Version .. " - " .. UpdateDate .. " - " .. UpdateNote)
- local Network = {}
- local Stats = {}
- local Rocket = {}
- local Gui = {}
- local Character = {}
- local Run = {}
- print("[C] Network")
- do
- local wfc = game.WaitForChild
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Remotes = wfc(ReplicatedStorage, "Remotes")
- local RemoteEvent = wfc(Remotes, "RemoteEvent")
- local BounceEvent = wfc(Remotes, "BounceEvent")
- local RemoteFunction = wfc(Remotes, "RemoteFunction")
- local K = {}
- local Funcs = {}
- local Queue = {}
- local function GetKey()
- local Key = K.Key * K.A % K.B
- K.Key = Key
- return Key
- end
- function Network:add(Name, Func)
- Funcs[Name] = Func
- if Queue[Name] then
- for i = 1, #Queue[Name] do
- Func(unpack(Queue[Name][i]))
- end
- end
- end
- function Network:send(Name, ...)
- RemoteEvent:FireServer(Name, GetKey(), ...)
- end
- function Network:bounce(Name, ...)
- BounceEvent:FireServer(Name, GetKey(), ...)
- end
- function Network:fetch(Name, ...)
- return RemoteFunction:InvokeServer(Name, GetKey(), ...)
- end
- local function Call(Name, ...)
- if Funcs[Name] then
- Funcs[Name](...)
- else
- if not Queue[Name] then
- Queue[Name] = {}
- end
- Queue[Name][#Queue[Name] + 1] = {
- ...
- }
- end
- end
- BounceEvent.OnClientEvent:Connect(function(Name, ...)
- if Funcs[Name] then
- return Funcs[Name](...)
- else
- if not Queue[Name] then
- Queue[Name] = {}
- end
- Queue[Name][#Queue[Name] + 1] = {
- ...
- }
- end
- end)
- RemoteEvent.OnClientEvent:Connect(Call)
- Network:add("K", function(Key)
- K = Key
- end)
- end
- print("[C] Stats")
- do
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- Network:add("Stats", function(S)
- Stats = S
- Stats.Fuel = Stats.MaxFuel
- Stats.Data = true
- end)
- repeat
- wait()
- until Stats.Data
- spawn(function()
- while wait(30) do
- Network:send("Save", Player, {
- RegenSpeed = Stats.RegenSpeed,
- MaxFuel = Stats.MaxFuel
- })
- end
- end)
- end
- print("[C] Rocket Tool")
- do
- local wfc = game.WaitForChild
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local PlayerGui = wfc(Player, "PlayerGui")
- local Sounds = wfc(PlayerGui, "Sounds")
- local EmptySound = wfc(Sounds, "Empty")
- local Mouse = Player:GetMouse()
- local RunService = game:GetService("RunService")
- local Debris = game:GetService("Debris")
- local Trash = wfc(workspace, "Trash")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Resources = wfc(ReplicatedStorage, "Resources")
- local FireParticle = wfc(Resources, "Fire")
- local RocketSound = wfc(Resources, "Rocket")
- local Trail = wfc(Resources, "Trail")
- local RSConnection
- Rocket.Flying = false
- local NoPower = Vector3.new(0, 0, 0)
- local VelocityPower = Vector3.new(50000, 50000, 50000)
- local GyroPower = Vector3.new(1000000, 1000000, 1000000)
- local Cooldown = false
- local CooldownTime = 1
- function StartEffects(LowerBody, Legs, LeftAtt0, LeftAtt1, RightAtt0, RightAtt1)
- local TrailLeft = Trail:Clone()
- TrailLeft.Name = "TrailLeft"
- TrailLeft.Parent = LowerBody
- TrailLeft.Attachment0 = LeftAtt0
- TrailLeft.Attachment1 = LeftAtt1
- local TrailRight = Trail:Clone()
- TrailRight.Name = "TrailRight"
- TrailRight.Parent = LowerBody
- TrailRight.Attachment0 = RightAtt0
- TrailRight.Attachment1 = RightAtt1
- local Rocket = RocketSound:Clone()
- Rocket.Parent = LowerBody
- Rocket:Play()
- local Fire = FireParticle:Clone()
- Fire.Parent = LowerBody
- Fire.Enabled = true
- for i = 1, #Legs do
- Legs[i].Transparency = 1
- do
- local BodyPart = Legs[i]:Clone()
- BodyPart:ClearAllChildren()
- BodyPart.Transparency = 0
- BodyPart.CanCollide = true
- BodyPart.CFrame = Legs[i].CFrame
- BodyPart.Parent = Trash
- Debris:AddItem(BodyPart, 1.5)
- spawn(function()
- for j = 0, 1, 0.1 do
- BodyPart.Transparency = j
- wait()
- end
- end)
- end
- end
- end
- function StopEffects(LowerBody, Legs)
- local TrailLeft, TrailRight = LowerBody:FindFirstChild("TrailLeft"), LowerBody:FindFirstChild("TrailRight")
- if TrailLeft then
- TrailLeft:Destroy()
- end
- if TrailRight then
- TrailRight:Destroy()
- end
- local Fire = LowerBody:FindFirstChild("Fire")
- if Fire then
- Fire:Destroy()
- end
- local Rocket = LowerBody:FindFirstChild("Rocket")
- if Rocket then
- Rocket:Stop()
- Rocket:Destroy()
- end
- for i = 1, #Legs do
- Legs[i].Transparency = 0
- end
- end
- Network:add("StartEffects", function(LowerBody, Legs, LeftAtt0, LeftAtt1, RightAtt0, RightAtt1)
- StartEffects(LowerBody, Legs, LeftAtt0, LeftAtt1, RightAtt0, RightAtt1)
- end)
- Network:add("StopEffects", function(LowerBody, Legs, LeftAtt0, LeftAtt1, RightAtt0, RightAtt1)
- StopEffects(LowerBody, Legs, LeftAtt0, LeftAtt1, RightAtt0, RightAtt1)
- end)
- function Rocket:Regen()
- repeat
- Stats.Fuel = Stats.Fuel + Stats.RegenSpeed
- wait(0.01)
- until RSConnection or Stats.Fuel >= Stats.MaxFuel
- if Stats.Fuel > Stats.MaxFuel then
- Stats.Fuel = Stats.MaxFuel
- end
- end
- local function Deactivate()
- if RSConnection then
- RSConnection:Disconnect()
- RSConnection = nil
- Network:send("Flying", Player, false)
- Rocket.Flying = false
- Character.Hits = {}
- spawn(function()
- Rocket:Regen()
- end)
- Character.Gyro.MaxTorque = NoPower
- Character.Vel.Velocity = NoPower
- Character.Vel.MaxForce = NoPower
- Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
- Network:bounce("StopEffects", Character.LowerTorso, Character.Legs, Character.LowerTorso, Character.Legs, Character.LeftAtt0, Character.LeftAtt1, Character.RightAtt0, Character.RightAtt1)
- StopEffects(Character.LowerTorso, Character.Legs, Character.LeftAtt0, Character.LeftAtt1, Character.RightAtt0, Character.RightAtt1)
- wait(CooldownTime)
- Cooldown = false
- end
- end
- function Activate()
- if not Cooldown and Character.Humanoid.Health > 0 and 0 < Stats.Fuel then
- Cooldown = true
- x = 0
- Network:send("Flying", Player, true)
- Rocket.Flying = true
- Network:bounce("StartEffects", Character.LowerTorso, Character.Legs, Character.LeftAtt0, Character.LeftAtt1, Character.RightAtt0, Character.RightAtt1)
- StartEffects(Character.LowerTorso, Character.Legs, Character.LeftAtt0, Character.LeftAtt1, Character.RightAtt0, Character.RightAtt1)
- Character.Gyro.MaxTorque = GyroPower
- Character.Vel.MaxForce = VelocityPower
- RSConnection = RunService.RenderStepped:Connect(function(dt)
- x = (x + dt * 1.5) % 1
- Stats.Fuel = Stats.Fuel - 0.5
- if Stats.Fuel <= 0 then
- Stats.Fuel = 0
- EmptySound:Play()
- Deactivate()
- return
- end
- local MouseCF = Mouse.Hit
- local Direction = MouseCF.p - Character.RootPart.CFrame.p
- Character.Gyro.CFrame = CFrame.new(Character.RootPart.CFrame.p, Character.RootPart.CFrame.p + Direction) * CFrame.Angles(-math.pi / 2, math.rad(x * 360), 0)
- Character.Vel.Velocity = Direction.unit * 100
- if Character.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown then
- Character.Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
- end
- end)
- end
- end
- function Rocket:Setup()
- local Tool = Instance.new("Tool")
- Tool.Name = "Rocket"
- Tool.CanBeDropped = false
- Tool.RequiresHandle = false
- Tool.TextureId = "rbxassetid://1526120813"
- Tool.Parent = Character.Backpack
- Tool.Activated:Connect(Activate)
- Tool.Deactivated:Connect(Deactivate)
- Tool.Unequipped:Connect(Deactivate)
- end
- end
- print("[C] Input")
- do
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local UserInputService = game:GetService("UserInputService")
- local Cooldown = false
- local CooldownTime = 2
- UserInputService.InputBegan:Connect(function(Input, GPE)
- if GPE then
- return
- end
- if Input.UserInputType == Enum.UserInputType.MouseButton1 and not Cooldown then
- Cooldown = true
- Stats.MaxFuel = Stats.MaxFuel + 1
- Network:send("Update", Player, Stats.MaxFuel)
- Rocket:Regen()
- wait(CooldownTime)
- Cooldown = false
- end
- end)
- end
- print("[C] Gui")
- do
- local wfc = game.WaitForChild
- local ud2 = UDim2.new
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local PlayerGui = wfc(Player, "PlayerGui")
- local FuelGui = wfc(PlayerGui, "Fuel")
- local FuelFrame = wfc(FuelGui, "Frame")
- local FuelBG = wfc(FuelFrame, "Fuelbar")
- local Fuelbar = wfc(FuelBG, "Bar")
- local FuelAmount = wfc(FuelFrame, "Amount")
- function Gui.HStep()
- Fuelbar:TweenSize(ud2(Stats.Fuel / Stats.MaxFuel, 0, 1, 0), "Out", "Sine", 0.1, true)
- FuelAmount.Text = "[" .. math.floor(Stats.Fuel) .. "/" .. Stats.MaxFuel .. "]"
- end
- end
- print("[C] Character")
- do
- local wfc = game.WaitForChild
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local function GetCharacter()
- repeat
- wait()
- until Player.Character and Player.Character.Parent
- local Char = Player.Character
- Character.C = Char
- Character.Backpack = wfc(Player, "Backpack")
- Character.Head = wfc(Char, "Head")
- Character.RootPart = wfc(Char, "HumanoidRootPart")
- Character.Humanoid = wfc(Char, "Humanoid")
- Character.LowerTorso = wfc(Char, "LowerTorso")
- Character.LeftUpperArm = wfc(Char, "LeftUpperArm")
- Character.RightUpperArm = wfc(Char, "RightUpperArm")
- Character.Legs = {
- wfc(Char, "LeftFoot"),
- wfc(Char, "LeftLowerLeg"),
- wfc(Char, "LeftUpperLeg"),
- wfc(Char, "RightFoot"),
- wfc(Char, "RightLowerLeg"),
- wfc(Char, "RightUpperLeg")
- }
- Character.LeftAtt0 = wfc(Character.LeftUpperArm, "LeftShoulderAttachment")
- Character.LeftAtt1 = wfc(Character.LeftUpperArm, "LeftElbowRigAttachment")
- Character.RightAtt0 = wfc(Character.RightUpperArm, "RightShoulderAttachment")
- Character.RightAtt1 = wfc(Character.RightUpperArm, "RightElbowRigAttachment")
- local Gyro = Instance.new("BodyGyro")
- Gyro.Name = "DirectionForce"
- Gyro.P = 10000
- Gyro.MaxTorque = Vector3.new(0, 0, 0)
- Gyro.Parent = Character.RootPart
- Character.Gyro = Gyro
- local Velocity = Instance.new("BodyVelocity")
- Velocity.Name = "FlyForce"
- Velocity.MaxForce = Vector3.new(0, 0, 0)
- Velocity.Parent = Character.RootPart
- Character.Vel = Velocity
- Rocket:Setup()
- Character.Hits = {}
- Character.Humanoid.Touched:Connect(function(Hit)
- if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Head") and Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Humanoid.Health > 0 and Players:GetPlayerFromCharacter(Hit.Parent) and Rocket.Flying and not Character.Hits[Hit.Parent] then
- Character.Hits[Hit.Parent] = true
- Network:send("Damage", Player, Character.Humanoid, Players:GetPlayerFromCharacter(Hit.Parent), Hit.Parent.Humanoid, Hit.Parent.Head)
- end
- end)
- end
- GetCharacter()
- Player.CharacterAdded:Connect(GetCharacter)
- end
- print("[C] Run")
- do
- local RunService = game:GetService("RunService")
- local RenderStepped = RunService.RenderStepped
- local Heartbeat = RunService.Heartbeat
- local RSLoop = {}
- local HBLoop = {
- Gui.HStep
- }
- RenderStepped:Connect(function()
- for i = 1, #RSLoop do
- RSLoop[i]()
- end
- end)
- Heartbeat:Connect(function()
- for i = 1, #HBLoop do
- HBLoop[i]()
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement