Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------
- --EDIT BY LUKAS242--
- ------------------------
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = owner
- local Event = script:WaitForChild("UserInput_Event")
- local Mouse = Player:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then return s[k] end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end,
- __call = function(self,...)
- local s = rawget(self,"_RealService")
- if s then return s(...) end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return self[s]
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- }
- rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- g.RunService = FakeService({
- RenderStepped = _rg:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- setmetatable(g,{
- __index=function(self,s)
- return _rg:GetService(s) or typeof(_rg[s])=="function"
- and function(_,...)return _rg[s](_rg,...)end or _rg[s]
- end,
- __newindex = fsmt.__newindex,
- __call = fsmt.__call
- })
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- local runDummyScript = function(f,scri)
- local oldenv = getfenv(f)
- local newenv = setmetatable({}, {
- __index = function(_, k)
- if k:lower() == 'script' then
- return scri
- else
- return oldenv[k]
- end
- end
- })
- setfenv(f, newenv)
- ypcall(function() f() end)
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- mas.Name = "CompiledModel"
- o1 = Instance.new("Tool")
- o2 = Instance.new("Part")
- o3 = Instance.new("SpecialMesh")
- o4 = Instance.new("Sound")
- o6 = Instance.new("Animation")
- o7 = Instance.new("Script")
- o8 = Instance.new("LocalScript")
- o10 = Instance.new("Script")
- o1.Name = "Rotorcycle"
- o1.Parent = mas
- o1.TextureId = "http://www.roblox.com/asset/?id=122306779"
- o1.GripForward = Vector3.new(-0, 3.9340253e-007, -1)
- o1.GripPos = Vector3.new(1.40000021, 1.96000028, -1.4000001)
- o1.GripUp = Vector3.new(0, 1, 3.9340253e-007)
- o1.ToolTip = "LOOK'N FOR ADVENTURE"
- o1.CanBeDropped = false
- o2.Name = "Handle"
- o2.Parent = o1
- o2.Position = Vector3.new(-7.00265312, 0.101328999, 49.6637764)
- o2.Rotation = Vector3.new(0.00306340586, 90, 0)
- o2.Elasticity = 0
- o2.FormFactor = Enum.FormFactor.Custom
- o2.Friction = 0
- o2.Size = Vector3.new(0.200000003, 0.200000003, 7.91000128)
- o2.CFrame = CFrame.new(-7.00265312, 0.101328999, 49.6637764, -6.97787764e-005, 0.000328140828, 1, 5.3466516e-005, 0.99999994, -0.000328137132, -1, 5.34436149e-005, -6.97963187e-005)
- o2.BottomSurface = Enum.SurfaceType.Smooth
- o2.TopSurface = Enum.SurfaceType.Smooth
- o3.Parent = o2
- o3.MeshId = "http://www.roblox.com/asset/?id=122309814"
- o3.Scale = Vector3.new(2.5, 2.5, 2.5)
- o3.TextureId = "http://www.roblox.com/asset/?id=127659109"
- o3.MeshType = Enum.MeshType.FileMesh
- o4.Name = "Running"
- o4.Parent = o2
- o4.SoundId = "http://www.roblox.com/asset/?id=122292723"
- o4.Looped = true
- o6.Name = "holdAni"
- o6.Parent = o1
- o6.AnimationId = "http://www.roblox.com/Asset?ID=104506550"
- o7.Name = "ThumbnailFixer"
- o7.Parent = o1
- o7.Disabled = true
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- function WaitForChild(parent,child)
- while not parent:FindFirstChild(child) do print("roped waiting for " .. child) wait() end
- return parent[child]
- end
- local handle = WaitForChild(script.Parent,'Handle')
- script.Parent.Grip = CFrame.new(1.40000021, 1.96000028, -1.4000001, 1, 0, 0, 0, 1, -3.9340253e-007, 0, 3.9340253e-007, 1)
- handle.Size = Vector3.new(0.2, 4.89, 6.08)
- end,o7)
- end))
- o8.Name = "continuumScript"
- o8.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- function WaitForChild(parent,child)
- while not parent:FindFirstChild(child) do print("roped waiting for " .. child) wait() end
- return parent[child]
- end
- local handle = WaitForChild(script.Parent,'Handle')
- local EngineSound = WaitForChild(handle,'Running')
- local HoldAni = WaitForChild(script.Parent,'holdAni')
- local left=false
- local right=false
- local up=false
- local down=false
- local mouse
- local Character
- local key_down_connect
- local key_up_connect
- local thrustForce
- local thrustMagnitude
- local thrustDirection
- local RotationForce
- local TurnGyro
- local HoldAniTrack
- local torsoWeld
- local SmokePart = Instance.new('Part')
- SmokePart.Transparency = 1
- SmokePart.Size = Vector3.new(0,0,0)
- local ExhaustSmoke = Instance.new('Smoke')
- ExhaustSmoke.Parent = SmokePart
- ExhaustSmoke.Size = .1
- ExhaustSmoke.RiseVelocity = .01
- ExhaustSmoke.Color = Color3.new(.5,.5,.5)
- local acceleration = 10
- local deceleration = 10
- local turnAlpha = .30
- local alphaDampening = .2
- local Equipped = false
- local LastPosition = nil
- local ActualVelocity = Vector3.new(0,0,0)
- local FakeHandle = nil
- local FrontWheel = Instance.new('Part')
- FrontWheel.FormFactor = 'Custom'
- FrontWheel.CanCollide = false
- FrontWheel.Size = Vector3.new(0,0,0)
- local WheelMesh = Instance.new('SpecialMesh')
- WheelMesh.MeshId = "http://www.roblox.com/asset/?id=122202439"
- WheelMesh.TextureId = "http://www.roblox.com/asset/?id=122185866"
- WheelMesh.Scale = Vector3.new(2.5,2.5,2.5)
- local Light = FrontWheel:Clone()
- local LightWeld = nil
- local FrontMotor = nil
- local BackWheel = FrontWheel:Clone()
- local BackMotor = nil
- local CurrentSpeed=0
- local turnSpeed=0
- local turnSpeedAim=5
- function ThrustUpdater()
- while Equipped do
- local direction = Character:FindFirstChild("Torso").CFrame.lookVector
- direction = Vector3.new(direction.x,0,direction.z).unit
- thrustForce.velocity = direction*(CurrentSpeed)
- EngineSound.Pitch = 1+(math.abs(CurrentSpeed/50)*1)
- if FrontMotor then
- FrontMotor.DesiredAngle=(999999999)* (-CurrentSpeed/math.abs(CurrentSpeed))
- FrontMotor.MaxVelocity = CurrentSpeed/250
- if BackMotor then
- BackMotor.DesiredAngle = FrontMotor.DesiredAngle
- BackMotor.MaxVelocity = FrontMotor.MaxVelocity
- end
- end
- RotationForce.angularvelocity = Vector3.new(0, turnSpeed, 0)
- if math.abs(turnSpeed)>alphaDampening then
- turnSpeed= turnSpeed-((alphaDampening)*(math.abs(turnSpeed)/turnSpeed))
- else
- turnSpeed = 0
- end
- local leanAmount= -turnSpeed*(math.pi/6)/4
- if not forwards or back then
- CurrentSpeed = CurrentSpeed*.99
- end
- local xzAngle = math.atan2(Character.Torso.CFrame.lookVector.z,0, Character.Torso.CFrame.lookVector.x)
- TurnGyro.cframe=CFrame.Angles(leanAmount*direction.x,0,leanAmount*direction.z)
- ExhaustSmoke.Opacity = (math.min(math.abs(CurrentSpeed),10)/10)*.5
- if LastPosition then
- local npos = Vector3.new(Character.Torso.CFrame.p.x,0,Character.Torso.CFrame.p.z)
- --(npos-LastPosition).magnitude
- local myspeed =Vector3.new(FakeHandle.Velocity.X,0,FakeHandle.Velocity.Z).magnitude
- local velocityDifference = math.abs((myspeed - (thrustForce.velocity.magnitude)))
- if myspeed>3 and thrustForce.velocity.magnitude>3 and velocityDifference> .7*thrustForce.velocity.magnitude then
- print('stopping: '..myspeed.." : " .. thrustForce.velocity.magnitude)
- CurrentSpeed=CurrentSpeed*.9
- end
- end
- LastPosition = Vector3.new(Character.Torso.CFrame.p.x,0,Character.Torso.CFrame.p.z)
- wait(1/60)
- end
- end
- function onEquipped(nmouse)
- print('got to equipped')
- Spawn(function()
- if Equipped then
- return
- end
- --
- Character=script.Parent.Parent
- local myTorso = WaitForChild(Character,'Torso')
- if not FakeHandle then
- FakeHandle = handle:Clone()
- FakeHandle.Name = 'FakeHandle'
- FakeHandle.Size = Vector3.new(1, 4.89, 6.08)
- FakeHandle:WaitForChild('Mesh').MeshId = "http://www.roblox.com/asset/?id=122185640"
- end
- FakeHandle.Parent = script.Parent
- FakeHandle.CFrame = myTorso.CFrame
- handle.Transparency = 1
- Spawn(function()
- FrontWheel.Parent = FakeHandle
- FrontMotor = Instance.new('Motor6D')
- FrontMotor.C0 = CFrame.Angles(0,math.pi/2,0)+Vector3.new(0,-1.1,-3.6)
- FrontMotor.C1 = CFrame.Angles(0,-math.pi/2,0)
- FrontMotor.Part0 = FakeHandle
- FrontMotor.Part1 = FrontWheel
- FrontMotor.Parent =FakeHandle
- WheelMesh:Clone().Parent = FrontWheel
- BackWheel.Parent = FakeHandle
- BackMotor = Instance.new('Motor6D')
- BackMotor.C0 = CFrame.Angles(0,math.pi/2,0)+Vector3.new(0,-1.1,2.8)
- BackMotor.C1 = CFrame.Angles(0,-math.pi/2,0)
- BackMotor.Part0 = FakeHandle
- BackMotor.Part1 = BackWheel
- BackMotor.Parent =FakeHandle
- WheelMesh:Clone().Parent = BackWheel
- Light.Parent = FakeHandle
- LightWeld = Instance.new('Weld')
- LightWeld.C0 = CFrame.new(0, 0, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
- LightWeld.C1 = CFrame.new(-0.140708923, -0.749996185, -0.9377985, -1.63912773e-007, -1.27675008e-008, -1.00000024, -2.05633661e-008, 0.99999994, 3.65663944e-009, 0.999999881, 5.65337004e-008, -7.4505806e-008)
- LightWeld.Part0 = FakeHandle
- LightWeld.Part1 = Light
- LightWeld.Parent = FakeHandle
- local tlight = Instance.new('SpotLight')
- tlight.Brightness = 5
- tlight.Angle=45
- tlight.Color = Color3.new(255/255,252/255,153/255)
- tlight.Parent = Light
- tlight.Range = 40
- end)
- CurrentSpeed=0
- turnSpeed=0
- print('got in if')
- mouse=nmouse
- Equipped = true
- handle.CFrame = myTorso.CFrame
- WaitForChild(Character,'Humanoid').PlatformStand = true
- if RotationForce then RotationForce:Destroy() end
- RotationForce = Instance.new('BodyAngularVelocity')
- RotationForce.maxTorque = Vector3.new(0, math.huge, 0)
- RotationForce.angularvelocity = Vector3.new(0, 0, 0)
- RotationForce.Parent = myTorso
- if thrustForce then thrustForce:Destroy() end
- 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 = FakeHandle--myTorso
- if TurnGyro then TurnGyro:Destroy() end
- TurnGyro = Instance.new('BodyGyro')
- TurnGyro.maxTorque = Vector3.new(5000,0,5000)
- TurnGyro.P = 300
- TurnGyro.D=100
- TurnGyro.Parent = myTorso
- Spawn(ThrustUpdater)
- if HoldAniTrack then HoldAniTrack:Stop() end
- HoldAniTrack = WaitForChild(Character,'Humanoid'):LoadAnimation(HoldAni)
- HoldAniTrack:Play()
- Spawn(function()
- myTorso.Anchored = true
- myTorso.CFrame = myTorso.CFrame+Vector3.new(0,3,0)
- if torsoWeld then torsoWeld:Destroy() end
- torsoWeld=Instance.new('Weld')
- torsoWeld.C0 = CFrame.Angles(0,0,0) + Vector3.new(0, -1.6, -0.7)
- torsoWeld.Part0 = myTorso
- torsoWeld.Part1 = FakeHandle
- torsoWeld.Parent = FakeHandle
- FakeHandle.CanCollide = true
- wait(.1)
- FakeHandle.CanCollide = true
- myTorso.Anchored = false
- myTorso.CFrame = myTorso.CFrame+Vector3.new(0,3,0)
- end)
- if key_down_connect then
- key_down_connect:disconnect()
- key_up_connect:disconnect()
- end
- key_down_connect=mouse.KeyDown:connect(keyDownFunc)
- key_up_connect=mouse.KeyUp:connect(keyUpFunc)
- SmokePart.Parent = FakeHandle
- local tweld=Instance.new('Weld')
- tweld.C0 = CFrame.new(0.600000024, 1.10000014, -2.20000005, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- tweld.Part0 = SmokePart
- tweld.Part1 = FakeHandle
- tweld.Parent = SmokePart
- EngineSound:Play()
- Character.Humanoid.WalkSpeed = 0
- --end
- end)
- end
- function onUnequipped()
- Equipped = false
- if SmokePart then
- SmokePart.Parent = nil
- end
- if FakeHandle then
- FakeHandle:Remove()
- FakeHandle = nil
- end
- handle.Transparency = 0
- --handle.Size = Vector3.new(0.2, 0.2, 0.2)
- forwards = false
- left = false
- back = false
- right = false
- if RotationForce then
- RotationForce:Destroy()
- RotationForce=nil
- end
- if thrustForce then
- thrustForce:Destroy()
- thrustForce=nil
- end
- if TurnGyro then
- TurnGyro:Destroy()
- TurnGyro=nil
- end
- if HoldAniTrack then
- HoldAniTrack:Stop()
- end
- if torsoWeld then
- torsoWeld:Destroy()
- torsoWeld=nil
- end
- if key_down_connect then
- key_down_connect:disconnect()
- key_down_connect=nil
- end
- if key_up_connect then
- key_up_connect:disconnect()
- key_up_connect=nil
- end
- if EngineSound then
- EngineSound:Stop()
- end
- if Character and Character:FindFirstChild('Humanoid') then
- Character.Humanoid.WalkSpeed = 16
- Character.Humanoid.PlatformStand = false
- end
- print("I unequipped!")
- end
- function keyUpFunc(key)
- if key == nil then return end
- local key = key:lower()
- if key == "w" then
- forwards = false
- elseif key == "a" then
- left = false
- elseif key == "s" then
- back = false
- elseif key == "d" then
- right = false
- end
- end
- local LastSpace = tick()
- function keyDownFunc(key)
- if key == nil then return end
- if inIntro then return end
- local key = key:lower()
- if key == "w" then
- forwards = true
- while forwards do
- CurrentSpeed = math.min(70,CurrentSpeed+(acceleration*(1/30)))
- wait(1/30)
- end
- elseif key == "a" then
- left = true
- while left do
- turnSpeed= math.min(5,turnSpeed+(turnAlpha))
- wait(1/30)
- end
- elseif key == "s" then
- back = true
- while back do
- if CurrentSpeed>0 then
- CurrentSpeed = math.max(-20,CurrentSpeed-(deceleration*2.8*(1/30)))
- else
- CurrentSpeed = math.max(-20,CurrentSpeed-(deceleration*(1/30)))
- end
- wait(1/30)
- end
- elseif key == "d" then
- right = true
- while right do
- turnSpeed= math.max(-5,turnSpeed-(turnAlpha))
- wait(1/30)
- end
- elseif key == ' ' then
- if tick()-LastSpace>1.9 then
- LastSpace = tick()
- local bforce = Instance.new('BodyForce')
- bforce.force = Vector3.new(0,25000,0)
- bforce.Parent = FakeHandle
- wait(.1)
- bforce:Destroy()
- end
- end
- end
- script.Parent.Unequipped:connect(onUnequipped)
- script.Parent.Equipped:connect(onEquipped)
- end,o8)
- end))
- o10.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- -- Nascardavid12 made this motorcycle. work's to be put in starterpack.
- -- Thank you for using a Nascardavid12 Model.
Add Comment
Please, Sign In to add comment