Advertisement
Guest User

Chams

a guest
Mar 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. do -- cham_stuff
  2. cham_stuff = {
  3. enabled = false,
  4. ally_chams = true,
  5. cham_folder = Instance.new("Folder", cg)
  6. }
  7.  
  8. function cham_stuff:CreateCham(plr)
  9. local player_folder = Instance.new("Folder", self.cham_folder)
  10. player_folder.Name = tostring(plr)
  11.  
  12. local char = plr.Character or plr.CharacterAdded:wait()
  13. local tor = char:WaitForChild("HumanoidRootPart")
  14. local hum = char:WaitForChild("Humanoid")
  15.  
  16. for i, v in pairs(char:GetChildren()) do
  17. if v:IsA("PVInstance") and v.Name ~= "HumanoidRootPart" then
  18. local box = Instance.new("BoxHandleAdornment")
  19. box.Size = functions:GetSizeOfObj(v)
  20. box.Name = "Cham"
  21. box.Adornee = v
  22. box.AlwaysOnTop = true
  23. box.ZIndex = 5
  24. box.Transparency = self.enabled and 0.5 or 1
  25. box.Color3 = functions:GetTeamColor(plr)
  26. box.Parent = player_folder
  27. end
  28. end
  29.  
  30. plr.CharacterRemoving:connect(function()
  31. self:RemoveCham(plr)
  32. plr.CharacterAdded:wait()
  33. self:CreateCham(plr)
  34. end)
  35.  
  36. hum.Died:connect(function()
  37. self:RemoveCham(plr)
  38. plr.CharacterAdded:wait()
  39. self:CreateCham(plr)
  40. end)
  41. end
  42.  
  43. function cham_stuff:RemoveCham(plr)
  44. local find = self.cham_folder:FindFirstChild(tostring(plr))
  45. if find then
  46. find:Destroy()
  47. end
  48. end
  49.  
  50. function cham_stuff:UpdateChamColor(plr)
  51. local player_folder = self.cham_folder:FindFirstChild(tostring(plr))
  52. if player_folder then
  53. local color = functions:GetTeamColor(plr)
  54.  
  55. for i, v in pairs(player_folder:GetChildren()) do
  56. v.Color3 = color
  57. end
  58. end
  59. end
  60.  
  61. function cham_stuff:SetTrans(trans, player_folder)
  62. for i, v in pairs(player_folder:GetChildren()) do
  63. v.Transparency = trans
  64. end
  65. end
  66.  
  67. function cham_stuff:UpdateCham(plr, ignorelist)
  68. local player_folder = self.cham_folder:FindFirstChild(tostring(plr))
  69.  
  70. if player_folder then
  71. if not self.enabled then return self:SetTrans(1, player_folder) end
  72.  
  73. local char = plr.Character
  74.  
  75. if not self.ally_chams and plr.Team == p.Team then
  76. return self:SetTrans(1, player_folder)
  77. end
  78.  
  79. if c and char then
  80. local their_head = char:FindFirstChild("Head")
  81. local their_tor = char:FindFirstChild("HumanoidRootPart")
  82. local their_hum = char:FindFirstChild("Humanoid")
  83. local my_head = c:FindFirstChild("Head")
  84. local my_tor = c:FindFirstChild("HumanoidRootPart")
  85.  
  86. if their_hum then
  87. if their_hum.Health <= 0 then
  88. return self:SetTrans(1, player_folder)
  89. end
  90. end
  91.  
  92. if their_head and their_tor and my_head and my_tor then
  93. if (my_tor.Position - their_tor.Position).magnitude > 2048 then
  94. return self:SetTrans(1, player_folder)
  95. end
  96.  
  97. --raycast(workspace,Ray.new(client.camera.cframe.p,rel),ignorelist)
  98.  
  99. local p = workspace:FindPartOnRayWithIgnoreList(Ray.new(client.camera.cframe.p, (their_head.Position - client.camera.cframe.p)), ignorelist)
  100.  
  101. if p then
  102. return self:SetTrans(0, player_folder)
  103. else
  104. return self:SetTrans(0.3, player_folder)
  105. end
  106. end
  107. end
  108.  
  109. return self:SetTrans(0, player_folder)
  110. end
  111. end
  112.  
  113. function cham_stuff:Init()
  114. functions:RunLoop("Cham_Update", function()
  115. local ignorelist = {c, ca, workspace.Ignore}
  116. for i, v in pairs(ps:GetPlayers()) do
  117. ignorelist[#ignorelist+1] = v.Character
  118. end
  119.  
  120. for i, v in pairs(ps:GetPlayers()) do
  121. self:UpdateCham(v, ignorelist)
  122. end
  123.  
  124. end, r.RenderStepped)
  125.  
  126. for i, v in pairs(ps:GetPlayers()) do
  127. if v ~= p then
  128. spawn(function()
  129. self:CreateCham(v)
  130. end)
  131.  
  132. v.Changed:connect(function(prop)
  133. self:UpdateChamColor(v)
  134. end)
  135. end
  136. end
  137.  
  138. ps.PlayerAdded:connect(function(plr)
  139. self:CreateCham(plr)
  140. plr.Changed:connect(function(prop)
  141. self:UpdateChamColor(plr)
  142. end)
  143. end)
  144.  
  145. ps.PlayerRemoving:connect(function(plr)
  146. self:RemoveCham(plr)
  147. end)
  148. end
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement