View difference between Paste ID: hkXN8Wea and BrEPNV5t
SHOW: | | - or go back to the newest paste.
1
--just put this on the top of a script and boom 89% works
2
--note this does not work on big scripts
3
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
4
local Player,game,owner = owner,game
5
local RealPlayer = Player
6
do
7
    local rp = RealPlayer
8
    script.Parent = rp.Character
9
   
10
    --RemoteEvent for communicating
11
    local Event = Instance.new("RemoteEvent")
12
    Event.Name = "UserInput_Event"
13
 
14
    --Fake event to make stuff like Mouse.KeyDown work
15
    local function fakeEvent()
16
        local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
17
        t.connect = t.Connect
18
        return t
19
    end
20
 
21
    --Creating fake input objects with fake variables
22
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
23
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
24
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
25
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
26
    end}
27
    --Merged 2 functions into one by checking amount of arguments
28
    CAS.UnbindAction = CAS.BindAction
29
 
30
    --This function will trigger the events that have been :Connect()'ed
31
    local function te(self,ev,...)
32
        local t = m[ev]
33
        if t and t._fakeEvent then
34
            for _,f in pairs(t.Functions) do
35
                f(...)
36
            end
37
        end
38
    end
39
    m.TrigEvent = te
40
    UIS.TrigEvent = te
41
 
42
    Event.OnServerEvent:Connect(function(plr,io)
43
        if plr~=rp then return end
44
        m.Target = io.Target
45
        m.Hit = io.Hit
46
        if not io.isMouse then
47
            local b = io.UserInputState == Enum.UserInputState.Begin
48
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
49
                return m:TrigEvent(b and "Button1Down" or "Button1Up")
50
            end
51
            for _,t in pairs(CAS.Actions) do
52
                for _,k in pairs(t.Keys) do
53
                    if k==io.KeyCode then
54
                        t.Function(t.Name,io.UserInputState,io)
55
                    end
56
                end
57
            end
58
            m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
59
            UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
60
        end
61
    end)
62
    Event.Parent = NLS([==[
63
    local Player = game:GetService("Players").LocalPlayer
64
    local Event = script:WaitForChild("UserInput_Event")
65
 
66
    local Mouse = Player:GetMouse()
67
    local UIS = game:GetService("UserInputService")
68
    local input = function(io,a)
69
        if a then return end
70
        --Since InputObject is a client-side instance, we create and pass table instead
71
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
72
    end
73
    UIS.InputBegan:Connect(input)
74
    UIS.InputEnded:Connect(input)
75
 
76
    local h,t
77
    --Give the server mouse data 30 times every second, but only if the values changed
78
    --If player is not moving their mouse, client won't fire events
79
    while wait(1/30) do
80
        if h~=Mouse.Hit or t~=Mouse.Target then
81
            h,t=Mouse.Hit,Mouse.Target
82
            Event:FireServer({isMouse=true,Target=t,Hit=h})
83
        end
84
    end]==],Player.Character)
85
 
86
    ----Sandboxed game object that allows the usage of client-side methods and services
87
    --Real game object
88
    local _rg = game
89
 
90
    --Metatable for fake service
91
    local fsmt = {
92
        __index = function(self,k)
93
            local s = rawget(self,"_RealService")
94
            if s then return s[k] end
95
        end,
96
        __newindex = function(self,k,v)
97
            local s = rawget(self,"_RealService")
98
            if s then s[k]=v end
99
        end,
100
        __call = function(self,...)
101
            local s = rawget(self,"_RealService")
102
            if s then return s(...) end
103
        end
104
    }
105
    local function FakeService(t,RealService)
106
        t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
107
        return setmetatable(t,fsmt)
108
    end
109
 
110
    --Fake game object
111
    local g = {
112
        GetService = function(self,s)
113
            return self[s]
114
        end,
115
        Players = FakeService({
116
            LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
117
        },"Players"),
118
        UserInputService = FakeService(UIS,"UserInputService"),
119
        ContextActionService = FakeService(CAS,"ContextActionService"),
120
    }
121
    rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
122
    g.service = g.GetService
123
   
124
    g.RunService = FakeService({
125
        RenderStepped = _rg:GetService("RunService").Heartbeat,
126
        BindToRenderStep = function(self,name,_,fun)
127
            self._btrs[name] = self.Heartbeat:Connect(fun)
128
        end,
129
        UnbindFromRenderStep = function(self,name)
130
            self._btrs[name]:Disconnect()
131
        end,
132
    },"RunService")
133
 
134
    setmetatable(g,{
135
        __index=function(self,s)
136
            return _rg:GetService(s) or typeof(_rg[s])=="function"
137
            and function(_,...)return _rg[s](_rg,...)end or _rg[s]
138
        end,
139
        __newindex = fsmt.__newindex,
140
        __call = fsmt.__call
141
    })
142
    --Changing owner to fake player object to support owner:GetMouse()
143
    game,owner = g,g.Players.LocalPlayer
144
end
145
 
146
 
147
148
149
repeat wait() until game:IsLoaded() and game:service("Players").LocalPlayer.Character ~= nil;
150
wait(0.4) 
151
for i, v in pairs(game:service("Players").LocalPlayer.Character:children()) do 
152
if v ~= script then 
153
v:Destroy() 
154
end 
155
end 
156
157
local player = game:service("Players").LocalPlayer
158
local mouse = player:GetMouse() 
159
local cam = workspace.CurrentCamera 
160
local char = player.Character 
161
local Torsoz = char:findFirstChild("Torso") 
162
local NV = Vector3.new() 
163
local Main 
164
local W,S = false,false 
165
local DoublePress = {nil,0} 
166
script.Parent = char 
167
168
local TrailParts = {} 
169
local Acceleration = 0.08 
170
local Speed = 0 
171
local MinSpeed = 0 
172
local MaxSpeed = 3.2 
173
local DesiredDirection = cam.CoordinateFrame.lookVector 
174
local Direction = DesiredDirection 
175
local Roll = 0 
176
local AllowTrails = true 
177
178
script.Name = "AdvFlight" 
179
180
local P = Instance.new("Part") 
181
P.Anchored = true 
182
P.CanCollide = false 
183
P.Name = "Part" 
184
P.formFactor = "Custom" 
185
P.Size = Vector3.new(0.2,0.2,0.2) 
186
P.Locked = true 
187
P.TopSurface = 10 
188
P.BottomSurface = 10 
189
P.FrontSurface = 10 
190
P.BackSurface = 10 
191
P.LeftSurface = 10 
192
P.RightSurface = 10 
193
P.Material = "Pebble" 
194
P.BrickColor = BrickColor.new("White") 
195
196
local shipp 
197
local shadow 
198
local campart 
199
200
function RAY(pos, dir, startpos, endpos, distleft, collidedlist) 
201
collidedlist = collidedlist or {char} 
202
startpos = startpos or pos 
203
distleft = distleft or dir.unit * dir.magnitude 
204
endpos = endpos or pos + distleft 
205
local ray = Ray.new(pos, distleft) 
206
local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist) 
207
if hitz ~= nil then 
208
if hitz.CanCollide == false then 
209
table.insert(collidedlist, hitz) 
210
local newpos = enz 
211
local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude) 
212
if newdistleft ~= NV then 
213
return RAY(newpos-(dir*0.01), dir, startpos, endpos, newdistleft+(dir*0.01), collidedlist) 
214
end 
215
end 
216
end 
217
return hitz, enz, ray 
218
end 
219
220
function FindSurface(part, position) 
221
local obj = part.CFrame:pointToObjectSpace(position) 
222
local siz = part.Size/2 
223
for i,v in pairs(Enum.NormalId:GetEnumItems()) do 
224
local vec = Vector3.FromNormalId(v) 
225
local wvec = part.CFrame:vectorToWorldSpace(vec) 
226
local vz = (obj)/(siz*vec) 
227
if (math.abs(vz.X-1) < 0.01 or math.abs(vz.Y-1) < 0.01 or math.abs(vz.Z-1) < 0.01) then
228
return wvec,vec 
229
end 
230
end 
231
if part.className == "WedgePart" then 
232
return part.CFrame:vectorToWorldSpace(Vector3.new(0,0.707,-0.707)), Vector3.new(0,0.707,-0.707) 
233
end 
234
end 
235
236
function HSV(H,S,V) 
237
H = H % 360 
238
local C = V * S 
239
local H2 = H/60 
240
local X = C * (1 - math.abs((H2 %2) -1)) 
241
local color = Color3.new(0,0,0) 
242
if H2 <= 0 then 
243
color = Color3.new(C,0,0) 
244
elseif 0 <= H2 and H2 <= 1 then 
245
color = Color3.new(C,X,0) 
246
elseif 1 <= H2 and H2 <= 2 then 
247
color = Color3.new(X,C,0) 
248
elseif 2 <= H2 and H2 <= 3 then 
249
color = Color3.new(0,C,X) 
250
elseif 3 <= H2 and H2 <= 4 then 
251
color = Color3.new(0,X,C) 
252
elseif 4 <= H2 and H2 <= 5 then 
253
color = Color3.new(X,0,C) 
254
elseif 5 <= H2 and H2 <= 6 then 
255
color = Color3.new(C,0,X) 
256
end 
257
local m = V - C
258
return Color3.new(color.r + m, color.g + m, color.b + m) 
259
end 
260
261
function Build(shiptype) 
262
AllowTrails = true 
263
for i, v in pairs(char:children()) do 
264
if v.className == "Model" and v.Name == "Ship" then 
265
v:remove() 
266
end 
267
end 
268
for i, v in pairs(TrailParts) do 
269
for _,V in pairs(v[3]) do 
270
V:Destroy() 
271
end 
272
end 
273
local mdl = Instance.new("Model", char) 
274
mdl.Name = "Ship" 
275
276
------------------------ Speeder Ship Type -----------------------------
277
if shiptype == "Speeder" then 
278
279
shipp = P:Clone() 
280
shipp.Parent = mdl 
281
shipp.Size = Vector3.new(1,1,2.2) 
282
local shipwing1 = P:Clone() 
283
shipwing1.Parent = mdl 
284
shipwing1.Size = Vector3.new(0.6,1.2,2) 
285
local mesh = Instance.new("SpecialMesh", shipwing1) 
286
mesh.MeshType = "Wedge" 
287
local shipwing2 = shipwing1:Clone() 
288
shipwing2.Parent = mdl 
289
campart = P:Clone() 
290
campart.Transparency = 1 
291
local shipwing21 = P:Clone() 
292
shipwing21.Parent = mdl 
293
shipwing21.Size = Vector3.new(0.32,1.1,2.6) 
294
local mesh = Instance.new("SpecialMesh", shipwing21) 
295
mesh.MeshType = "Wedge" 
296
local shipwing22 = shipwing21:Clone() 
297
shipwing22.Parent = mdl 
298
campart = P:Clone() 
299
campart.Transparency = 1 
300
301
local shipwi = P:Clone() 
302
shipwi.Parent = mdl 
303
shipwi.Size = Vector3.new(1,1,1.2) 
304
local mesh = Instance.new("SpecialMesh", shipwi) 
305
mesh.MeshType = "Wedge" 
306
local shipwi2 = P:Clone() 
307
shipwi2.Parent = mdl 
308
shipwi2.Size = Vector3.new(0.7,0.7,0.84) 
309
shipwi2.Material = "SmoothPlastic" 
310
shipwi2.BrickColor = BrickColor.new("Pastel blue") 
311
shipwi2.Reflectance = 0.6 
312
local mesh = Instance.new("SpecialMesh", shipwi2) 
313
mesh.MeshType = "Wedge" 
314
315
shadow = P:Clone() 
316
shadow.Parent = mdl 
317
shadow.Name = "Shadow" 
318
shadow.Material = "SmoothPlastic" 
319
shadow.BrickColor = BrickColor.new("Really black") 
320
local mesh = Instance.new("SpecialMesh",shadow) 
321
mesh.MeshType = "Sphere" 
322
323
TrailParts = {} 
324
table.insert(TrailParts,{shipp,1,{},cam.CoordinateFrame.p,CFrame.new(0,0,1),0.5,18}) 
325
table.insert(TrailParts,{shipwing1,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15}) 
326
table.insert(TrailParts,{shipwing2,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15}) 
327
for _, V in pairs(TrailParts) do 
328
for i = 1, V[7] do 
329
local p = P:Clone() 
330
local mesh = Instance.new("SpecialMesh", p) 
331
mesh.MeshId = "http://www.roblox.com/asset/?id=9856898" 
332
mesh.TextureId = "http://www.roblox.com/asset/?id=48358980" 
333
p.BrickColor = BrickColor.new("Dark stone grey") 
334
table.insert(V[3],p) 
335
end 
336
end 
337
338
function ReposParts() 
339
shipwing1.CFrame = shipp.CFrame * CFrame.new(-1.1,-0.195,-0.14) * CFrame.Angles(0,0,math.pi/2) 
340
shipwing2.CFrame = shipp.CFrame * CFrame.new(1.1,-0.195,-0.14) * CFrame.Angles(0,0,-math.pi/2) 
341
shipwing21.CFrame = shipp.CFrame * CFrame.new(-1.05,-0.34,-0.45) * CFrame.Angles(0,0,math.pi/2) 
342
shipwing22.CFrame = shipp.CFrame * CFrame.new(1.05,-0.34,-0.45) * CFrame.Angles(0,0,-math.pi/2) 
343
shipwi.CFrame = shipp.CFrame * CFrame.new(0,0,-1.7) 
344
shipwi2.CFrame = shipwi.CFrame * CFrame.new(0,0.015,-0.015) 
345
campart.CFrame = shipp.CFrame + Vector3.new(0,1.5,0) 
346
end 
347
cam.CameraSubject = campart 
348
cam.CameraType = "Track" 
349
350
shipp.CFrame = CFrame.new(NV,Direction) + cam.CoordinateFrame.p 
351
ReposParts() 
352
353
end 
354
355
AllowTrails = true 
356
end 
357
Build("Speeder") 
358
359
function B1D() 
360
Build("Speeder") 
361
end 
362
363
function RollThatSht(direc) 
364
if Roll == 0 then 
365
for i = 1, 50 do 
366
Roll = (-360 + math.cos(math.pi/50*i) * 360) * direc 
367
wait(0.02) 
368
end 
369
Roll = 0 
370
end 
371
end 
372
373
function KD(key) 
374
if key == "w" then 
375
W = true 
376
elseif key == "s" then 
377
S = true 
378
end 
379
380
local rollpls = 0 
381
if key == DoublePress[1] and tick() - DoublePress[2] < 0.32 then 
382
DoublePress = {nil,0} 
383
if key == "a" then 
384
rollpls = -1 
385
elseif key == "d" then 
386
rollpls = 1 
387
end 
388
end 
389
390
DoublePress = {key,tick()} 
391
if rollpls ~= 0 then 
392
RollThatSht(rollpls) 
393
end 
394
end 
395
396
function KU(key) 
397
if key == "w" then 
398
W = false 
399
elseif key == "s" then 
400
S = false 
401
end 
402
end 
403
404
function Equip() 
405
end 
406
407
function Unequip() 
408
end 
409
410
mouse.Icon = "rbxasset://textures\\GunCursor.png" 
411
mouse.Button1Down:connect(B1D) 
412
mouse.KeyDown:connect(KD) 
413
mouse.KeyUp:connect(KU) 
414
415
416
417
local count = 0 
418
local hue = 0 
419
--game:GetService("RunService").Stepped:connect(function() 
420
while wait(0.02) do 
421
422
------ Speed --------
423
local valu = (0.002*MaxSpeed) + ((Speed/MaxSpeed)*Acceleration)
424
if W == true then 
425
Speed = Speed + valu 
426
elseif S == true then 
427
Speed = Speed - valu 
428
end 
429
if Speed > MaxSpeed then 
430
Speed = MaxSpeed 
431
elseif Speed < MinSpeed then 
432
Speed = MinSpeed 
433
end 
434
435
------ left/right tilt ---------
436
local target = 180 + math.floor(math.deg(math.atan2(DesiredDirection.x,DesiredDirection.z))) 
437
local current = 180 + math.floor(math.deg(math.atan2(Direction.x,Direction.z))) 
438
local swing = 0 
439
if math.abs(math.abs(current-target) - 360) > math.abs(target-current) then 
440
swing = target-current 
441
else 
442
swing = (current > target and -(math.abs(current-target) - 360)) or (current < target and math.abs(current-target) - 360) 
443
end 
444
445
DesiredDirection = cam.CoordinateFrame.lookVector 
446
------ direction smoothening ------ 
447
local dir = DesiredDirection.unit 
448
if Direction ~= dir then 
449
if (Direction - dir).magnitude < 0.01 then 
450
Direction = dir 
451
else 
452
local dist = ((dir - Direction).unit * (dir - Direction).magnitude) /10 
453
Direction = (Direction + dist).unit 
454
end 
455
end 
456
457
shipp.CFrame = (CFrame.new(NV,Direction) + shipp.Position + (Direction.unit * Speed)) * CFrame.Angles(0,0,math.rad(Roll) + math.rad(swing/2)) 
458
ReposParts() 
459
460
------ shadow ------
461
local ghitz, genz = RAY(shipp.Position,Vector3.new(0,-26,0)) 
462
local angles = CFrame.new() 
463
if ghitz ~= nil and ghitz.className ~= "Terrain" and ((ghitz.className == "Part" and ghitz.Shape == Enum.PartType.Block) or (ghitz.className ~= "Part" and ghitz:IsA("BasePart"))) then 
464
local wvec,vec = FindSurface(ghitz,genz) 
465
angles = CFrame.new(NV,wvec) * CFrame.Angles(-math.pi/2,0,0) 
466
elseif ghitz ~= nil and (ghitz.className == "Part" and ghitz.Shape == Enum.PartType.Ball) then 
467
angles = (CFrame.new(ghitz.Position, genz) - ghitz.Position) * CFrame.Angles(-math.pi/2,0,0) 
468
end 
469
shadow.CFrame = CFrame.new(genz) * angles 
470
shadow.Transparency = 0.5 + (((shipp.Position - genz).magnitude /26)*0.5)
471
shadow.Mesh.Scale = (Vector3.new(4.4,0.25,4.4) * 5) * (1-(shipp.Position - genz).magnitude /26)
472
473
------- Trails ----------------------- 
474
if AllowTrails == true then 
475
count = (count+1)%1 
476
hue = (hue+1) % 360
477
local rgb = HSV(hue,0.65,0.85) 
478
for _,v in pairs(TrailParts) do 
479
local to = (v[1].CFrame * v[5]).p
480
if Speed > MinSpeed + 0.2 then 
481
v[2] = (v[2]%#v[3]) + 1 
482
v[3][v[2]].CFrame = CFrame.new((v[4] + to)/2,to) * CFrame.Angles(math.pi/2,math.rad(Roll) + math.rad(swing/2),0) 
483
v[3][v[2]].Mesh.Scale = Vector3.new(v[6],(v[4] - to).magnitude*2,v[6]) 
484
v[3][v[2]].Mesh.VertexColor = Vector3.new(rgb.r,rgb.g,rgb.b) 
485
v[3][v[2]].Transparency = 0.15 
486
v[3][v[2]].Parent = game.Players.LocalPlayer.Character
487
else 
488
v[2] = (v[2]%#v[3]) + 1 
489
v[3][v[2]].Parent = nil 
490
end 
491
492
v[4] = to 
493
end 
494
end 
495
496
end