Advertisement
Bendy928443534

ok

Jul 5th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.03 KB | None | 0 0
  1. repeat wait() until script:WaitForChild'Owner'.Value
  2. local Player = script:WaitForChild'Owner'.Value
  3. script.Owner:destroy()
  4. repeat wait() until Player.Character
  5. local scriptName = "Corruption"
  6. local stopped=false
  7. local remotes;
  8. function WaitForChildOfClass(where,class,timeout)
  9. local start = tick();
  10. local ret;
  11. repeat ret=where:FindFirstChildOfClass(class) wait() until ret or tick()-start>=(timeout or 15)
  12. if(not ret)then warn("timeout") repeat wait()until nil else return ret end
  13. end
  14.  
  15. local GUID = {}
  16. do
  17. GUID.IDs = {};
  18. function GUID:new(len)
  19. local id;
  20. if(not len)then
  21. id = (tostring(function() end))
  22. id = id:gsub("function: ","")
  23. else
  24. local function genID(len)
  25. local newID = ""
  26. for i = 1,len do
  27. newID = newID..string.char(math.random(48,90))
  28. end
  29. return newID
  30. end
  31. repeat id = genID(len) until not GUID.IDs[id]
  32. local oid = id;
  33. id = {Trash=function() GUID.IDs[oid]=nil; end;Get=function() return oid; end}
  34. GUID.IDs[oid]=true;
  35. end
  36. return id
  37. end
  38. end
  39.  
  40. local instanceID = GUID:new()
  41.  
  42. local Replicated = script:WaitForChild'Replication':Clone();
  43. script.Replication:Destroy()
  44. local GUID = {}
  45. do
  46. GUID.IDs = {};
  47. function GUID:new(len)
  48. local id;
  49. if(not len)then
  50. id = (tostring(function() end))
  51. id = id:gsub("function: ","")
  52. else
  53. local function genID(len)
  54. local newID = ""
  55. for i = 1,len do
  56. newID = newID..string.char(math.random(48,90))
  57. end
  58. return newID
  59. end
  60. repeat id = genID(len) until not GUID.IDs[id]
  61. local oid = id;
  62. id = {Trash=function() GUID.IDs[oid]=nil; end;Get=function() return oid; end}
  63. GUID.IDs[oid]=true;
  64. end
  65. return id
  66. end
  67. end
  68.  
  69.  
  70. local fakeEvent = function()
  71. local t = {_fakeEvent=true,Waited={},Connected={}}
  72. t.Connect = function(self,f)
  73. local ft={}
  74. ft={Disconnected=false;disconnect=function(s) if(self.Function==ft)then self.Function=nil end s.Disconnected=true end}
  75. ft.Disconnect=ft.disconnect
  76.  
  77. ft.Func=function(...)
  78. for id,_ in next, t.Waited do
  79. t.Waited[id] = true
  80. end
  81. return f(...)
  82. end;
  83.  
  84. table.insert(self.Connected,ft)
  85. return ft;
  86. end
  87. t.connect = t.Connect
  88. t.Wait = function()
  89. local guid = GUID:new(25)
  90. local waitingId = guid:Get()
  91. t.Waited[waitingId]=false
  92. repeat wait() until t.Waited[waitingId]==true
  93. t.Waited[waitingId]=nil;
  94. guid:Trash()
  95. end
  96. t.wait = t.Wait
  97. return t
  98. end
  99.  
  100. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  101. local UsIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  102. local function te(self,ev,...)
  103. local t = self[ev]
  104. if t and t._fakeEvent and t.Connected then
  105. for i,v in next, t.Connected do
  106. if(v.Func and not v.Disconnected)then
  107. v.Func(...)
  108. else
  109. t.Connected[i]=nil
  110. end
  111. end
  112. end
  113. end
  114. m.TrigEvent = te
  115. UsIS.TrigEvent = te
  116.  
  117. NewInstance = function(instance,parent,properties)
  118. local inst = Instance.new(instance)
  119. inst.Parent = parent
  120. if(properties)then
  121. for i,v in next, properties do
  122. pcall(function() inst[i] = v end)
  123. end
  124. end
  125. return inst;
  126. end
  127.  
  128. local CF={N=CFrame.new,A=CFrame.Angles}
  129.  
  130. local Head = Player.Character:WaitForChild'Head'
  131. local Torso = Player.Character:WaitForChild'Torso'
  132. local LArm = Player.Character:WaitForChild'Left Arm'
  133. local RArm = Player.Character:WaitForChild'Right Arm'
  134. local LLeg = Player.Character:WaitForChild'Left Leg'
  135. local RLeg = Player.Character:WaitForChild'Right Leg'
  136. local Root = Player.Character:WaitForChild'HumanoidRootPart'
  137.  
  138. function newMotor(P0,P1,C0,C1)
  139. return NewInstance('Motor',P0,{Part0=P0,Part1=P1,C0=C0,C1=C1})
  140. end
  141.  
  142. local welds = {}
  143. local vars = {}
  144. local Hit = {}
  145.  
  146.  
  147. table.insert(welds,newMotor(Torso,Head,CF.N(0,1.5,0),CF.N()))
  148. table.insert(welds,newMotor(Root,Torso,CF.N(),CF.N()))
  149. table.insert(welds,newMotor(Torso,RLeg,CF.N(.5,-1,0),CF.N(0,1,0)))
  150. table.insert(welds,newMotor(Torso,RArm,CF.N(1.5,.5,0),CF.N(0,.5,0)))
  151. table.insert(welds,newMotor(Torso,LLeg,CF.N(-.5,-1,0),CF.N(0,1,0)))
  152. table.insert(welds,newMotor(Torso,LArm,CF.N(-1.5,.5,0),CF.N(0,.5,0)))
  153.  
  154. vars.WeldDefaults={}
  155. for i = 1,#welds do
  156. local v=welds[i]
  157. vars.WeldDefaults[i]=v.C0
  158. end
  159.  
  160. function GetTorso(char)
  161. return char:FindFirstChild'Torso' or char:FindFirstChild'UpperTorso' or char:FindFirstChild'LowerTorso' or char:FindFirstChild'HumanoidRootPart'
  162. end
  163.  
  164.  
  165. function DealDamage(data)
  166. local Who = data.Who;
  167. local MinDam = data.MinimumDamage or 15;
  168. local MaxDam = data.MaximumDamage or 30;
  169. local MaxHP = data.MaxHP or 1e5;
  170. local DamageColor = data.DamageColor or BrickColor.new'Really red'
  171.  
  172. local DB = data.Debounce or .2;
  173.  
  174. local CritData = data.Crit or {}
  175. local CritChance = CritData.Chance or 0;
  176. local CritMultiplier = CritData.Multiplier or 1;
  177.  
  178. local DamageEffects = data.DamageFX or {}
  179. local DeathEffect = DamageEffects.DeathEffect
  180.  
  181. assert(Who,"Specify someone to damage!")
  182.  
  183. local Humanoid = Who:FindFirstChildOfClass'Humanoid'
  184. local DoneDamage = math.random(MinDam,MaxDam) * (math.random(1,100) <= CritChance and CritMultiplier or 1)
  185. local remotes = Player.Character:WaitForChild(instanceID.."Remotes")
  186.  
  187. local canHit = true
  188. if(Humanoid)then
  189. for _, p in next, Hit do
  190. if p[1] == Humanoid then
  191. if(time() - p[2] <= DB) then
  192. canHit = false
  193. else
  194. Hit[_] = nil
  195. end
  196. end
  197. end
  198. if(canHit)then
  199. table.insert(Hit,{Humanoid,time()})
  200. local HitTorso = GetTorso(Who)
  201. local player = game:service'Players':GetPlayerFromCharacter(Who)
  202. if(Player.UserId == 5719877 or not player or player.UserId ~= 5719877 and player.UserId ~= 61573184 and player.UserId ~= 19081129)then
  203. if(Humanoid.MaxHealth >= MaxHP and Humanoid.Health > 0)then
  204. print'Got kill'
  205. Humanoid.Health = 0;
  206. Who:BreakJoints();
  207. if(DeathEffect)then remotes:WaitForChild'Pusher':FireAllClients(DeathEffect,Who,Humanoid) end
  208.  
  209. else
  210. local c = Instance.new("ObjectValue",Humanoid)
  211. c.Name = "creator"
  212. c.Value = Player
  213. game:service'Debris':AddItem(c,0.35)
  214. if(Who:FindFirstChild'Head' and Humanoid.Health > 0)then
  215. remotes:WaitForChild'Pusher':FireAllClients('ShowDamage',(Who.Head.CFrame * CF.N(0, 0, (Who.Head.Size.Z / 2)).p+Vector3.new(0,1.5,0)+Vector3.new(math.random(-2,2),0,math.random(-2,2))),DoneDamage,1.5,DamageColor.Color)
  216. end
  217. if(Humanoid.Health > 0 and Humanoid.Health-DoneDamage <= 0)then print'Got kill' if(DeathEffect)then remotes:WaitForChild'Pusher':FireAllClients(DeathEffect,Who,Humanoid) end end
  218. Humanoid.Health = Humanoid.Health - DoneDamage
  219. end
  220. end
  221. end
  222. end
  223. end
  224.  
  225.  
  226. function SetupRemotes(name)
  227. local ch = Player.Character
  228. local RemoteFolder = Instance.new("Folder",Player.Character)
  229. RemoteFolder.Name=name..'Remotes'
  230. local Pull = Instance.new("RemoteFunction",RemoteFolder)
  231. Pull.Name = 'Puller'
  232. Pull.OnServerInvoke = function(player,request,...)
  233. if(stopped)then return end
  234. if(request=='Welds')then
  235. return welds
  236. elseif(request=='Character')then
  237. return ch
  238. elseif(vars[request])then
  239. return vars[request]
  240. end
  241. end
  242. local Push = Instance.new("RemoteEvent",RemoteFolder)
  243. Push.Name = 'Pusher'
  244. Push.OnServerEvent:connect(function(player,request,...)
  245. local varargs={...}
  246. if(stopped)then return end
  247. if(request=='MouseEventCall')then
  248. local event = table.remove(varargs,1)
  249. if(m[event])then
  250. Push:FireAllClients(event,unpack(varargs))
  251. m:TrigEvent(event,unpack(varargs))
  252. end
  253. elseif(request=='MouseUpdate')then
  254. m.Target = varargs[1].Target
  255. m.Hit = varargs[1].Hit
  256. Push:FireAllClients("UpdatePos",m.Target,m.Hit)
  257. elseif(request=='Damage')then
  258. DealDamage(...)
  259. elseif(request=='Kill')then
  260. varargs[1]:BreakJoints()
  261. elseif(request=='Broadcast')then
  262. Push:FireAllClients(unpack(varargs))
  263. elseif(request=='SetVariable')then
  264. if(varargs[1])then
  265. vars[varargs[1]]=varargs[2]
  266. end
  267. elseif(request=='SetVariableAndBroadcast')then
  268. vars[varargs[1]]=varargs[2]
  269. Push:FireAllClients(unpack(varargs))
  270. elseif(request=='Drag')then
  271. --hitto,CFrame.new(Handle.Position)
  272. varargs[1].CFrame = varargs[2]
  273. end
  274. end)
  275.  
  276. local removing=false
  277. local signal;
  278. signal=RemoteFolder.AncestryChanged:connect(function()
  279. if((RemoteFolder.Parent~=ch or Push.Parent~=RemoteFolder or Pull.Parent~=RemoteFolder) and not removing)then
  280. removing=true
  281. signal:disconnect()
  282. RemoteFolder:Destroy()
  283. SetupRemotes(name)
  284. end
  285. end)
  286. remotes=RemoteFolder
  287. end
  288.  
  289. -- MODIFIABLE STUFF --
  290.  
  291.  
  292.  
  293. -- STOP MODIFIABLE STUFF --
  294. local signals = {} -- for l8r (stop commands, etc)
  295. local scripts = {}
  296.  
  297. function BreakSignal(signalOrName)
  298. for name,signal in next, signals do
  299. if(typeof(signalOrName)~='RBXScriptSignal' and name==signalOrName or signal==signalOrName)then
  300. signal:disconnect()
  301. signals[name]=nil
  302. break
  303. end
  304. end
  305. end
  306. local Hum;
  307. repeat wait() Hum=Player.Character:FindFirstChildOfClass'Humanoid' until Hum
  308. for _,v in next, Hum:GetPlayingAnimationTracks() do
  309. v:Stop(0);
  310. end
  311.  
  312. pcall(game.Destroy,Player.Character:FindFirstChild'Animate')
  313. pcall(game.Destroy,Hum:FindFirstChild'Animator')
  314.  
  315. function GiveScript(who)
  316. local pgui = WaitForChildOfClass(who,'PlayerGui')
  317. local scr = Replicated:Clone();
  318. scr.Name=instanceID
  319. scr.Parent = pgui
  320. scripts[who]=scr
  321. if(scr:FindFirstChild'Owner')then scr:WaitForChild'Owner'.Value = Player end
  322. scr.Disabled = false
  323. local signal;
  324. signal = pgui.DescendantRemoving:connect(function(o)
  325. wait()
  326. if(stopped)then BreakSignal(signal) return end
  327. if(scr.Parent~=pgui and not scr.Disabled)then
  328. local reparenting = pcall(function() scr.Parent=pgui end)
  329. if(not reparenting)then
  330. scr.Disabled=true
  331. BreakSignal(signal)
  332. scr:destroy()
  333. GiveScript(who)
  334. return
  335. end
  336. end
  337. end)
  338. signals[who.Name]=signal
  339. end
  340.  
  341. function stop()
  342. warn("Stopped "..scriptName)
  343. stopped=true
  344. for _,v in next, signals do
  345. BreakSignal(v)
  346. end
  347. remotes:WaitForChild'Pusher':FireAllClients("stop")
  348. remotes:destroy()
  349. for _,v in next, scripts do
  350. v.Disabled=true
  351. v:destroy()
  352. end
  353. script:Destroy()
  354. end
  355. function connect(v)
  356. if(stopped)then return end
  357. if(v==Player and not v.Character:FindFirstChild(instanceID.."Remotes"))then
  358. SetupRemotes(instanceID)
  359. end
  360. v.CharacterAdded:connect(function()
  361. GiveScript(v)
  362. if(v==Player)then
  363. SetupRemotes(instanceID)
  364. delay(.3,function() stop() end)
  365. end
  366. end)
  367. if(v.Character)then GiveScript(v) end
  368. if(v==Player)then
  369. v.Chatted:connect(function(c)
  370. if(c:lower()=="stopscript-")then
  371. stop()
  372. end
  373. end)
  374. end
  375. end
  376.  
  377. for _,v in next, game:service'Players':players() do
  378. connect(v)
  379. end
  380.  
  381. game:service'Players'.PlayerAdded:connect(connect)
  382. game:service'Players'.PlayerRemoving:connect(function(p)
  383. if(p==Player)then
  384. stop()
  385. end
  386. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement