Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local owner = owner or script:FindFirstAncestorOfClass("Player")
- local character = owner.Character
- local rootpart = character.HumanoidRootPart
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- local tool = Instance.new("Tool", owner.Backpack)
- tool.RequiresHandle = false
- tool.Name = "car"
- tool.CanBeDropped = false
- script.Parent = tool
- local hoverheight = 4
- local att = Instance.new("Attachment")
- att.CFrame = CFrame.new(0, -.5 - hoverheight, 0)
- local smoke = Instance.new("Smoke")
- smoke.Opacity = 0
- smoke.Size = .3
- local carrunning = Instance.new("Sound")
- carrunning.SoundId = "http://www.roblox.com/asset/?id=391824568"
- carrunning.Volume = 1
- carrunning.Looped = true
- local carstarting = Instance.new("Sound")
- carstarting.SoundId = "rbxassetid://912961304"
- carstarting.Volume = 2
- local equipped = false
- tool.Equipped:Connect(function()
- equipped = true
- att.Parent = rootpart
- smoke.Parent = att
- carrunning.Parent = rootpart
- carstarting.Parent = rootpart
- carstarting:Play()
- carrunning:Play()
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- att.Parent = nil
- carstarting.Parent = nil
- carrunning.Parent = nil
- smoke.Parent = nil
- carrunning:Stop()
- end)
- local param = RaycastParams.new()
- param.FilterDescendantsInstances = {character}
- local overlap = OverlapParams.new()
- overlap.FilterDescendantsInstances = {character}
- local crashids = {"rbxassetid://135850769", "rbxassetid://152274149", "rbxassetid://152273920", "rbxassetid://152273933"}
- local i = 0
- game:GetService("RunService").Stepped:Connect(function()
- if(equipped)then
- i += 1
- for i, v in next, character:GetDescendants() do
- if(v:IsA("BasePart"))then
- v.Anchored = false
- end
- end
- local onground = workspace:Raycast(rootpart.Position, Vector3.yAxis*-hoverheight, param)
- local mag = rootpart.AssemblyLinearVelocity.Magnitude
- if(mag >= 30 and mag <= 80 and i%3 == 0)then
- local parts = workspace:GetPartBoundsInRadius(rootpart.Position, rootpart.Size.Y*5, overlap)
- local damaged = {}
- for i, v in next, parts do
- if(v:FindFirstAncestorOfClass("Model") and v:FindFirstAncestorOfClass("Model"):FindFirstChildOfClass("Humanoid") and not damaged[v:FindFirstAncestorOfClass("Model"):FindFirstChildOfClass("Humanoid")])then
- damaged[v:FindFirstAncestorOfClass("Model"):FindFirstChildOfClass("Humanoid")] = true
- v:FindFirstAncestorOfClass("Model"):FindFirstChildOfClass("Humanoid"):TakeDamage(mag/10)
- local s = Instance.new("Sound", v)
- s.Volume = 1+mag/5
- s.SoundId = crashids[math.random(#crashids)]
- s:Play()
- task.delay(3, pcall, game.Destroy, s)
- end
- end
- elseif(mag >= 80 and i%3 == 0)then
- local parts = workspace:GetPartBoundsInRadius(rootpart.Position, rootpart.Size.Y*5, overlap)
- for i, v in next, parts do
- if(v.Name:lower() ~= "base" and v.Name:lower() ~= "baseplate")then
- pcall(function()
- v.Anchored = false
- v:BreakJoints()
- local vel = Instance.new("BodyVelocity", v)
- vel.maxForce = Vector3.one*math.huge
- vel.velocity = -CFrame.new(v.Position, rootpart.Position).lookVector*(mag/2)
- game:GetService("Debris"):AddItem(vel, .1)
- local s = Instance.new("Sound", v)
- s.Volume = 1+mag/5
- s.SoundId = crashids[math.random(#crashids)]
- s:Play()
- task.delay(3, pcall, game.Destroy, s)
- end)
- end
- end
- end
- if(onground)then
- smoke.Opacity = math.min(1, math.abs(mag/60)) - .3
- end
- carrunning.Pitch = .2+mag/60
- end
- end)
- NLS([[
- local owner = owner or script:FindFirstAncestorOfClass("Player")
- local character = owner.Character
- local rootpart = character.HumanoidRootPart
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- humanoid.UseJumpPower = true
- local hover = Instance.new("BodyPosition")
- hover.MaxForce = Vector3.one*math.huge
- local gyro = Instance.new("BodyGyro")
- gyro.MaxTorque = Vector3.one*math.huge
- gyro.P = 1e4
- local tool = script.Parent.Parent
- local rot = 0
- local velocity = Vector3.zero
- local rotdiff = 0
- local rotdiffx = 0
- local equipped = false
- tool.Equipped:Connect(function()
- equipped = true
- rot = rootpart.Orientation.Y
- gyro.Parent = rootpart
- humanoid.JumpPower = 0
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- gyro.Parent = nil
- hover.Parent = nil
- humanoid.JumpPower = 50
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
- velocity = Vector3.zero
- rotdiff = 0
- rotdiffx = 0
- humanoid.Sit = false
- end)
- local param = RaycastParams.new()
- param.FilterDescendantsInstances = {character}
- local uis = game:GetService("UserInputService")
- local moving = false
- local hoverheight = rootpart.Size.Y*2
- local rotspeed = 5
- local maxvel = math.huge
- local movespeed = 5
- local jitter = hoverheight/4
- local jump = 30
- local function clampvector(vec, maxx, maxy, maxz)
- return Vector3.new(math.clamp(vec.X, -maxx, maxx), math.clamp(vec.Y, -maxy, maxy), math.clamp(vec.Z, -maxz, maxz))
- end
- local rotating = false
- local jumping = false
- game:GetService("RunService").Stepped:Connect(function(t, dt)
- if(equipped)then
- for i, v in next, character:GetDescendants() do
- if(v:IsA("BasePart"))then
- v.Anchored = false
- end
- end
- local onground = workspace:Raycast(rootpart.Position, Vector3.yAxis*-hoverheight, param)
- if(not game:GetService("UserInputService"):GetFocusedTextBox())then
- if(uis:IsKeyDown(Enum.KeyCode.W))then
- velocity = velocity - (Vector3.zAxis*movespeed)
- end
- if(uis:IsKeyDown(Enum.KeyCode.S))then
- velocity = velocity + (Vector3.zAxis*movespeed)
- end
- if(uis:IsKeyDown(Enum.KeyCode.A))then
- rot = rot + (rotspeed*(60*dt))
- rotdiff = rotdiff + 1
- end
- if(uis:IsKeyDown(Enum.KeyCode.D))then
- rot = rot - (rotspeed*(60*dt))
- rotdiff = rotdiff - 1
- end
- if(uis:IsKeyDown(Enum.KeyCode.Space))then
- if(onground)then
- velocity = velocity + (Vector3.yAxis*(jump*60))
- jumping = true
- end
- end
- if(not uis:IsKeyDown(Enum.KeyCode.S) and not uis:IsKeyDown(Enum.KeyCode.W))then
- moving = false
- else
- moving = true
- end
- if(not uis:IsKeyDown(Enum.KeyCode.A) or not uis:IsKeyDown(Enum.KeyCode.D) or jumping)then
- rotating = false
- else
- rotating = true
- end
- else
- rotating = false
- moving = false
- end
- if(not moving)then
- velocity = velocity / (1+(dt*2))
- end
- if(not rotating)then
- rotdiff = rotdiff / (1+(dt*2))
- rotdiffx = rotdiffx / (1+(dt*2))
- end
- velocity = clampvector(velocity, 0, 40*maxvel, 60*maxvel)
- rot = rot%360
- rotdiff = math.clamp(rotdiff, -20, 20)
- if(not onground)then
- rotdiffx = math.clamp(rootpart.AssemblyLinearVelocity.Y/4, -20, 20)
- end
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
- humanoid.Sit = true
- gyro.CFrame = CFrame.Angles(math.rad(rotdiffx), math.rad(rot), math.rad(rotdiff))
- if(onground or jumping)then
- if(onground)then jumping = false end
- hover.Parent = rootpart
- hover.Position = (rootpart.CFrame*CFrame.new(0,-rootpart.CFrame.Y,0)*CFrame.new((Vector3.yAxis*(onground.Position.Y+((hoverheight - jitter)+(jitter*math.cos(tick()*20)))))+(velocity/(1/dt)))).Position
- else
- hover.Parent = nil
- end
- end
- end)
- ]], script)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement