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