Advertisement
HenloMyDude

camshake test

Aug 20th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.62 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6. PLAYER = owner
  7. CHARACTER = PLAYER.Character
  8. Debris = game:GetService("Debris")
  9. mouse = PLAYER:GetMouse()
  10.  
  11. IT = Instance.new
  12.  
  13. Torso = CHARACTER.Torso
  14.  
  15. fakemouse = NLS([[
  16.  
  17. local me = game:service'Players'.localPlayer;
  18. local mouse = me:GetMouse();
  19. local UIS = game:service'UserInputService'
  20. local ch = me.Character;
  21.  
  22. local UserEvent = ch:WaitForChild('UserInputEvent',30)
  23.  
  24. UIS.InputChanged:connect(function(io,gpe)
  25. if(io.UserInputType == Enum.UserInputType.MouseMovement)then
  26. UserEvent:FireServer{Mouse=true,Target=mouse.Target,Hit=mouse.Hit}
  27. end
  28. end)
  29.  
  30. mouse.Changed:connect(function(o)
  31. if(o == 'Target' or o == 'Hit')then
  32. UserEvent:FireServer{Mouse=true,Target=mouse.Target,Hit=mouse.Hit}
  33. end
  34. end)
  35.  
  36. UIS.InputBegan:connect(function(io,gpe)
  37. if(gpe)then return end
  38. UserEvent:FireServer{InputObject=true,KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}
  39. end)
  40.  
  41. UIS.InputEnded:connect(function(io,gpe)
  42. if(gpe)then return end
  43. UserEvent:FireServer{InputObject=true,KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}
  44. end)
  45.  
  46. mouse.KeyDown:connect(function(k)
  47. UserEvent:FireServer{KeyEvent='Down',Key=k}
  48. end)
  49.  
  50. mouse.KeyUp:connect(function(k)
  51. UserEvent:FireServer{KeyEvent='Up',Key=k}
  52. end)
  53.  
  54. local ClientProp = ch:WaitForChild('GetClientProperty',30)
  55.  
  56. local sounds = {}
  57.  
  58.  
  59. function regSound(o)
  60. if(o:IsA'Sound')then
  61.  
  62. local lastLoudness = o.PlaybackLoudness
  63. ClientProp:InvokeServer(o,lastLoudness)
  64. table.insert(sounds,{o,lastLoudness})
  65. --ClientProp:InvokeServer(o,o.PlaybackLoudness)
  66. end
  67. end
  68.  
  69. ClientProp.OnClientInvoke = function(inst,prop)
  70. if(inst == 'RegSound')then
  71. regSound(prop)
  72. for i = 1, #sounds do
  73. if(sounds[i][1] == prop)then
  74. return sounds[i][2]
  75. end
  76. end
  77. else
  78. return inst[prop]
  79. end
  80. end
  81.  
  82. for _,v in next, workspace:GetDescendants() do regSound(v) end
  83. workspace.DescendantAdded:connect(regSound)
  84. me.Character.DescendantAdded:connect(regSound)
  85.  
  86. game:service'RunService'.RenderStepped:connect(function()
  87. for i = 1, #sounds do
  88. local tab = sounds[i]
  89. local object,last=unpack(tab)
  90. if(object.PlaybackLoudness ~= last)then
  91. sounds[i][2]=object.PlaybackLoudness
  92. ClientProp:InvokeServer(object,sounds[i][2])
  93. end
  94. end
  95. end)
  96.  
  97. ]],script)
  98.  
  99. fakemouse.Name = "FakeMouse"
  100.  
  101. local FakeMouse = script.FakeMouse:Clone();
  102. FakeMouse.Parent = PLAYER.Character;
  103. script.FakeMouse:Destroy()
  104. do
  105. local GUID = {}
  106. do
  107. GUID.IDs = {};
  108. function GUID:new(len)
  109. local id;
  110. if(not len)then
  111. id = (tostring(function() end))
  112. id = id:gsub("function: ","")
  113. else
  114. local function genID(len)
  115. local newID = ""
  116. for i = 1,len do
  117. newID = newID..string.char(math.random(48,90))
  118. end
  119. return newID
  120. end
  121. repeat id = genID(len) until not GUID.IDs[id]
  122. local oid = id;
  123. id = {Trash=function() GUID.IDs[oid]=nil; end;Get=function() return oid; end}
  124. GUID.IDs[oid]=true;
  125. end
  126. return id
  127. end
  128. end
  129.  
  130. local AHB = Instance.new("BindableEvent")
  131.  
  132. local FPS = 30
  133.  
  134. local TimeFrame = 0
  135.  
  136. local LastFrame = tick()
  137. local Frame = 1/FPS
  138.  
  139. game:service'RunService'.Heartbeat:connect(function(s,p)
  140. TimeFrame = TimeFrame + s
  141. if(TimeFrame >= Frame)then
  142. for i = 1,math.floor(TimeFrame/Frame) do
  143. AHB:Fire()
  144. end
  145. LastFrame=tick()
  146. TimeFrame=TimeFrame-Frame*math.floor(TimeFrame/Frame)
  147. end
  148. end)
  149.  
  150.  
  151. function swait(dur)
  152. if(dur == 0 or typeof(dur) ~= 'number')then
  153. AHB.Event:wait()
  154. else
  155. for i = 1, dur*FPS do
  156. AHB.Event:wait()
  157. end
  158. end
  159. end
  160.  
  161. local oPlayer = PLAYER
  162. local Player = oPlayer
  163.  
  164. local loudnesses={}
  165. script.Parent = Player.Character
  166. local CoAS = {Actions={}}
  167. local Event = Instance.new("RemoteEvent")
  168. Event.Name = "UserInputEvent"
  169. Event.Parent = Player.Character
  170. local Func = Instance.new("RemoteFunction")
  171. Func.Name = "GetClientProperty"
  172. Func.Parent = Player.Character
  173. local fakeEvent = function()
  174. local t = {_fakeEvent=true,Waited={},Connected={}}
  175. t.Connect = function(self,f)
  176. local ft={}
  177. ft={Disconnected=false;disconnect=function(s) if(self.Function==ft)then self.Function=nil end s.Disconnected=true end}
  178. ft.Disconnect=ft.disconnect
  179.  
  180. ft.Func=function(...)
  181. for id,_ in next, t.Waited do
  182. t.Waited[id] = true
  183. end
  184. return f(...)
  185. end;
  186.  
  187. table.insert(self.Connected,ft)
  188. return ft;
  189. end
  190. t.connect = t.Connect
  191. t.Wait = function()
  192. local guid = GUID:new(25)
  193. local waitingId = guid:Get()
  194. t.Waited[waitingId]=false
  195. repeat swait() until t.Waited[waitingId]==true
  196. t.Waited[waitingId]=nil;
  197. guid:Trash()
  198. end
  199. t.wait = t.Wait
  200. return t
  201. end
  202. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  203. local UsIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  204. local Run = {RenderStepped=fakeEvent()}
  205.  
  206. function CoAS:BindAction(name,fun,touch,...)
  207. CoAS.Actions[name] = {Name=name,Function=fun,Keys={...}}
  208. end
  209. function CoAS:UnbindAction(name)
  210. CoAS.Actions[name] = nil
  211. end
  212. local function te(self,ev,...)
  213. local t = self[ev]
  214. if t and t._fakeEvent and t.Connected then
  215. for i,v in next, t.Connected do
  216. if(v.Func and not v.Disconnected)then
  217. v.Func(...)
  218. else
  219. t.Connected[i]=nil
  220. end
  221. end
  222. end
  223. end
  224. m.TrigEvent = te
  225. UsIS.TrigEvent = te
  226. Run.TrigEvent = te
  227. Event.OnServerEvent:Connect(function(plr,io)
  228. if plr~=Player then return end
  229. --[[table.foreach(io,print)
  230. print'---']]
  231. if io.Mouse then
  232. m.Target = io.Target
  233. m.Hit = io.Hit
  234. MOUSEPOS = m.Hit.p
  235. elseif io.KeyEvent then
  236. m:TrigEvent('Key'..io.KeyEvent,io.Key)
  237. elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
  238. if io.UserInputState == Enum.UserInputState.Begin then
  239. m:TrigEvent("Button1Down")
  240. else
  241. m:TrigEvent("Button1Up")
  242. end
  243. end
  244. if(not io.KeyEvent and not io.Mouse)then
  245.  
  246. for n,t in pairs(CoAS.Actions) do
  247. for _,k in pairs(t.Keys) do
  248. if k==io.KeyCode then
  249. t.Function(t.Name,io.UserInputState,io)
  250. end
  251. end
  252. end
  253. if io.UserInputState == Enum.UserInputState.Begin then
  254. UsIS:TrigEvent("InputBegan",io,false)
  255. else
  256. UsIS:TrigEvent("InputEnded",io,false)
  257. end
  258. end
  259. end)
  260.  
  261. Func.OnServerInvoke = function(plr,inst,play)
  262. if plr~=Player then return end
  263. if(inst and typeof(inst) == 'Instance' and inst:IsA'Sound')then
  264. loudnesses[inst]=play
  265. end
  266. end
  267.  
  268. function GetClientProperty(inst,prop)
  269. if(prop == 'PlaybackLoudness' and loudnesses[inst])then
  270. return loudnesses[inst]
  271. elseif(prop == 'PlaybackLoudness')then
  272. return Func:InvokeClient(Player,'RegSound',inst)
  273. end
  274. return Func:InvokeClient(Player,inst,prop)
  275. end
  276. local oldGame = game;
  277. function GetFakePlayer()
  278. local oldPlayer = Player;
  279. local fakePlayer = newproxy(true)
  280. getmetatable(fakePlayer).__index = function(s,i)
  281. if(i == 'GetMouse')then
  282. return function() return m; end
  283. end
  284. return Player[i]
  285. end
  286. getmetatable(fakePlayer).__newindex = function(s,i,v)
  287. Player[i]=v
  288. end
  289. getmetatable(fakePlayer).__call=function(self,...)
  290. if(self == fakePlayer)then self = Player end
  291. local wh = {...}
  292. local name = table.remove(wh,1)
  293. for i,v in next, wh do
  294. wh[i]=v
  295. end
  296. if(name == 'GetMouse')then
  297. return m;
  298. end
  299. return self(name,unpack(wh))
  300. end
  301. getmetatable(fakePlayer).__namecall=function(self,...)
  302. if(self == fakePlayer)then self = Player end
  303. local tuple={...}
  304. local name = table.remove(tuple,#tuple)
  305.  
  306. if(name == 'GetMouse')then
  307. return m;
  308. else
  309. return self[name](self,unpack(tuple))
  310. end
  311. end
  312.  
  313. return fakePlayer
  314. end
  315. local oll = LoadLibrary;
  316. function LoadLibrary(libtard)
  317. local libtarddestroyed=oll(libtard)
  318. if(libtard=='RbxUtility')then
  319. local library={Create=function(obj)
  320. local inst = Instance.new(obj)
  321. return function(props)
  322. for prop,valu in next, props do
  323. inst[prop]=valu
  324. end
  325. return inst
  326. end
  327. end}
  328. setmetatable(library,{__index=libtarddestroyed,__newindex=function(s,i,v) libtarddestroyed[i]=v end})
  329.  
  330. return library
  331. else
  332. return libtarddestroyed
  333. end
  334. end
  335. fakePlayer = GetFakePlayer()
  336. local function GetService(s,i)
  337. local service = s:GetService(i)
  338. if(i == 'Players')then
  339. local oldService = service;
  340. local fakeService = newproxy(true)
  341. getmetatable(fakeService).__index = function(s,i)
  342. if(s == fakeService)then s=oldService end
  343. if(i == 'LocalPlayer' or i == 'localPlayer')then
  344. return fakePlayer
  345. elseif(i == 'oPlayer')then
  346. return oPlayer
  347. else
  348. return s[i]
  349. end
  350. end
  351. getmetatable(fakeService).__newindex = function(s,i,v)
  352. if(s == fakeService)then s=oldService end
  353. s[i]=v
  354. end
  355. getmetatable(fakeService).__call=function(self,...)
  356. if(self == fakeService)then self = oldService end
  357. local wh = {...}
  358. local name = table.remove(wh,1)
  359. for i,v in next, wh do
  360. wh[i]=v
  361. end
  362. return self(name,unpack(wh))
  363. end
  364. getmetatable(fakeService).__namecall=function(self,...)
  365. if(self == fakeService)then self = oldService end
  366. local tuple={...}
  367. local name = table.remove(tuple,#tuple)
  368.  
  369. return self[name](self,unpack(tuple))
  370. end
  371. getmetatable(fakeService).__metatable = 'gay'
  372. return fakeService
  373. elseif(i == 'RunService')then
  374. local oldService = service;
  375. local fakeService = newproxy(true)
  376. getmetatable(fakeService).__index = function(s,i)
  377. if(s == fakeService)then s=oldService end
  378. return Run[i] or s[i]
  379. end
  380. getmetatable(fakeService).__newindex = function(s,i,v)
  381. if(s == fakeService)then s=oldService end
  382. s[i]=v
  383. end
  384. getmetatable(fakeService).__call=function(self,...)
  385. if(self == fakeService)then self = oldService end
  386. local wh = {...}
  387. local name = table.remove(wh,1)
  388. for i,v in next, wh do
  389. wh[i]=v
  390. end
  391. return self(name,unpack(wh))
  392. end
  393. getmetatable(fakeService).__namecall=function(self,...)
  394. if(self == fakeService)then self = oldService end
  395. local tuple={...}
  396. local name = table.remove(tuple,#tuple)
  397.  
  398. return self[name](self,unpack(tuple))
  399. end
  400. getmetatable(fakeService).__metatable = 'gay'
  401. return fakeService
  402. elseif(i == 'UserInputService')then
  403. return UsIS
  404. elseif(i == 'ContextActionService')then
  405. return CoAS;
  406. else
  407. return service
  408. end
  409. end
  410.  
  411. local new = Instance.new;
  412. Instance = {}
  413. Instance.new = function(inst,obje)
  414. local lp = GetService(oldGame,'Players').localPlayer
  415. local instance = new(inst)
  416. if(inst=='ObjectValue')then
  417. local fake = newproxy(true)
  418. getmetatable(fake).__index=function(self,index)
  419. if(self==fake)then self=instance end
  420. return self[index]
  421. end
  422. getmetatable(fake).__newindex=function(self,index,value)
  423. if(self==fake)then self=instance end
  424. if(index=='Value' and typeof(value)~='Instance' and value==fakePlayer)then
  425. self[index]=oPlayer
  426. else
  427. self[index]=value
  428. end
  429. end
  430. getmetatable(fake).__call=function(self,...)
  431. if(self == fake)then self = instance end
  432. local wh = {...}
  433. local name = table.remove(wh,1)
  434. for i,v in next, wh do
  435. if(v == fake)then v = instance end
  436. wh[i]=v
  437. end
  438. return self(name,unpack(wh))
  439. end
  440. getmetatable(fake). __namecall=function(self,...)
  441. if(self == fake)then self = instance end
  442. local tuple={...}
  443. local name = table.remove(tuple,#tuple)
  444. return self[name](self,unpack(tuple))
  445. end
  446. return fake
  447. elseif(inst=='aaa')then
  448. local fake = newproxy(true)
  449. getmetatable(fake).__index=function(self,index)
  450. if(self==fake)then self=instance end
  451. if(index=='PlaybackLoudnes')then
  452. return GetClientProperty(instance,'PlaybackLoudness')
  453. end
  454. return self[index]
  455. end
  456. getmetatable(fake).__newindex=function(self,index,value)
  457. if(self==fake)then self=instance end
  458. self[index]=value
  459. end
  460. getmetatable(fake).__call=function(self,...)
  461. if(self == fake)then self = instance end
  462. local wh = {...}
  463. local name = table.remove(wh,1)
  464. for i,v in next, wh do
  465. if(v == fake)then v = instance end
  466. wh[i]=v
  467. end
  468. return self(name,unpack(wh))
  469. end
  470. getmetatable(fake). __namecall=function(self,...)
  471. if(self == fake)then self = instance end
  472. local tuple={...}
  473. local name = table.remove(tuple,#tuple)
  474. return self[name](self,unpack(tuple))
  475. end
  476. return fake
  477. else
  478. instance.Parent = obje
  479. return instance;
  480. end
  481.  
  482. end
  483. local serviceFunctions={
  484. service=true,
  485. GetService=true,
  486. }
  487. local fakeGame = newproxy(true)
  488. getmetatable(fakeGame).__index = function(s,i)
  489. if(s == fakeGame)then s=oldGame end
  490. local serv = GetService(oldGame,i)
  491. if serviceFunctions[i] then
  492. return GetService
  493. elseif(serv)then
  494. return serv
  495. else
  496. return s[i]
  497. end
  498. end
  499. getmetatable(fakeGame).__newindex = function(s,i,v)
  500. if(s == fakeGame)then s=oldGame end
  501. s[i]=v
  502. end
  503. getmetatable(fakeGame).__call=function(self,...)
  504. if(self == fakeGame)then self = oldGame end
  505. local wh = {...}
  506. local name = table.remove(wh,1)
  507. for i,v in next, wh do
  508. if(v == fakeGame)then v = oldGame end
  509. wh[i]=v
  510. end
  511. if serviceFunctions[name] then
  512. return GetService(self,unpack(wh))
  513. else
  514. return self(name,unpack(wh))
  515. end
  516. end
  517. getmetatable(fakeGame). __namecall=function(self,...)
  518. if(self == fakeGame)then self = oldGame end
  519. local tuple={...}
  520. local name = table.remove(tuple,#tuple)
  521.  
  522. local funcToCall=self[name]
  523.  
  524. if serviceFunctions[name] then
  525. return GetService(self,unpack(tuple))
  526. else
  527. return self[name](self,unpack(tuple))
  528. end
  529. end
  530. getmetatable(fakeGame).__metatable = 'gay'
  531.  
  532. coroutine.wrap(function()
  533. while true do
  534. Run:TrigEvent('RenderStepped')
  535. swait()
  536. end
  537. end)()
  538. game=fakeGame
  539. UserInputService,ContextActionService = UsIS,CoAS
  540. end
  541.  
  542.  
  543.  
  544. shake = NLS([[
  545.  
  546. ArtificialHB = Instance.new("BindableEvent", script)
  547. ArtificialHB.Name = "ArtificialHB"
  548.  
  549. script:WaitForChild("ArtificialHB")
  550.  
  551. frame = 1/60
  552. tf = 0
  553. allowframeloss = false
  554. tossremainder = false
  555. lastframe = tick()
  556. script.ArtificialHB:Fire()
  557.  
  558. game:GetService("RunService").Heartbeat:connect(function(s, p)
  559. tf = tf + s
  560. if tf >= frame then
  561. if allowframeloss then
  562. ArtificialHB:Fire()
  563. lastframe = tick()
  564. else
  565. for i = 1, math.floor(tf / frame) do
  566. ArtificialHB:Fire()
  567. end
  568. lastframe = tick()
  569. end
  570. if tossremainder then
  571. tf = 0
  572. else
  573. tf = tf - frame * math.floor(tf / frame)
  574. end
  575. end
  576. end)
  577.  
  578. function PositiveAngle(NUMBER)
  579. if NUMBER >= 0 then
  580. NUMBER = 0
  581. end
  582. return NUMBER
  583. end
  584.  
  585. function NegativeAngle(NUMBER)
  586. if NUMBER <= 0 then
  587. NUMBER = 0
  588. end
  589. return NUMBER
  590. end
  591.  
  592. function Swait(NUMBER)
  593. if NUMBER == 0 or NUMBER == nil then
  594. ArtificialHB.Event:wait()
  595. else
  596. for i = 1, NUMBER do
  597. ArtificialHB.Event:wait()
  598. end
  599. end
  600. end
  601. wait()
  602. VT = Vector3.new
  603. MRANDOM = math.random
  604. local A = script:FindFirstChild("Timer").Value
  605. local B = script:FindFirstChild("Shake").Value
  606. local HUMANOID = script.Parent:FindFirstChildOfClass("Humanoid")
  607. local TIMER = math.ceil(A) or 35
  608. local SHAKE = math.ceil(B) or 5
  609. if HUMANOID then
  610. local FADER = SHAKE/TIMER
  611. for i = 1, TIMER do
  612. Swait()
  613. HUMANOID.CameraOffset = VT(MRANDOM(-(SHAKE-(FADER*i)),(SHAKE-(FADER*i)))/10,MRANDOM(-(SHAKE-(FADER*i)),(SHAKE-(FADER*i)))/10,MRANDOM(-(SHAKE-(FADER*i)),(SHAKE-(FADER*i)))/10)
  614. end
  615. HUMANOID.CameraOffset = VT(0,0,0)
  616. end
  617.  
  618. ]],script)
  619.  
  620. shake.Name = "CamShake"
  621.  
  622. function CameraShake(AREA,RANGE,SHAKE,TIMER)
  623. for index, CHILD in pairs(workspace:GetChildren()) do
  624. if CHILD:FindFirstChildOfClass("Humanoid") then
  625. local HUMAN = CHILD:FindFirstChildOfClass("Humanoid")
  626. local ROOT = HUMAN.Torso
  627. if ROOT and game.Players:GetPlayerFromCharacter(CHILD) then
  628. if (ROOT.Position - AREA).Magnitude <= RANGE then
  629. if CHILD:FindFirstChild("CamShake") then
  630. Debris:AddItem(CHILD:FindFirstChild("CamShake"),0.05)
  631. end
  632. local CAMSHAKE = script.CamShake:Clone()
  633. CAMSHAKE.Parent = CHILD
  634. local TIMER_V = IT("NumberValue",CAMSHAKE)
  635. TIMER_V.Name = "Timer"
  636. TIMER_V.Value = TIMER
  637. local SHAKE_V = IT("NumberValue",CAMSHAKE)
  638. SHAKE_V.Name = "Shake"
  639. SHAKE_V.Value = SHAKE
  640. CAMSHAKE.Disabled = false
  641. Debris:AddItem(CAMSHAKE,15)
  642. end
  643. end
  644. end
  645. end
  646. end
  647.  
  648. mouse.Button1Down:connect(function()
  649. CameraShake(Torso,100,100000,100)
  650. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement