Advertisement
C-H-4-0-S

Windoe matt

Nov 15th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. local players = game:GetService("Players")
  2. local player = players.LocalPlayer
  3. local camera = workspace.CurrentCamera
  4.  
  5. local Range = 10 -- Define the range (e.g., 10 studs)
  6.  
  7. local function getPartsInViewport(maxDistance)
  8. local partsInViewport = {}
  9. for _, part in ipairs(workspace:GetDescendants()) do
  10. if part:IsA("BasePart") then
  11. local distance = player:DistanceFromCharacter(part.Position)
  12. if distance <= maxDistance then
  13. local _, isVisible = camera:WorldToViewportPoint(part.Position)
  14. if isVisible then
  15. table.insert(partsInViewport, part)
  16. end
  17. end
  18. end
  19. end
  20. return partsInViewport
  21. end
  22.  
  23. while true do
  24. wait()
  25. local tool = player.Character and player.Character:FindFirstChildOfClass("Tool")
  26. local parts = getPartsInViewport(Range)
  27.  
  28. if tool and tool:FindFirstChild("Handle") then
  29. for _, part in ipairs(parts) do
  30. if part and part.Parent and part.Parent ~= player.Character and part.Parent:FindFirstChildWhichIsA("Humanoid") and part.Parent:FindFirstChildWhichIsA("Humanoid").Health > 0 then
  31. tool:Activate()
  32. firetouchinterest(tool.Handle, part, 0)
  33. firetouchinterest(tool.Handle, part, 1)
  34. end
  35. end
  36. end
  37. end
  38.  
  39.  
  40. --// Setting \--
  41. local range = 10
  42.  
  43. --// Variable \--
  44. local player = game:GetService("Players").LocalPlayer
  45.  
  46. --// Script \--
  47. game:GetService("RunService").RenderStepped:Connect(function()
  48. local p = game.Players:GetPlayers()
  49. for i = 2, #p do local v = p[i].Character
  50. if v and v:FindFirstChild("Humanoid") and v.Humanoid.Health > 0 and v:FindFirstChild("HumanoidRootPart") and player:DistanceFromCharacter(v.HumanoidRootPart.Position) <= range then
  51. local tool = player.Character and player.Character:FindFirstChildOfClass("Tool")
  52. if tool and tool:FindFirstChild("Handle") then
  53. tool:Activate()
  54. for i,v in next, v:GetChildren() do
  55. if v:IsA("BasePart") then
  56. firetouchinterest(tool.Handle,v,0)
  57. firetouchinterest(tool.Handle,v,1)
  58. end
  59. end
  60. end
  61. end
  62. end
  63. end)
  64.  
  65. local connections = getgenv().configs and getgenv().configs.connection
  66. if connections then
  67. local Disable = configs.Disable
  68. for i,v in connections do
  69. v:Disconnect()
  70. end
  71. Disable:Fire()
  72. Disable:Destroy()
  73. table.clear(configs)
  74. end
  75.  
  76. local Disable = Instance.new("BindableEvent")
  77. getgenv().configs = {
  78. connections = {},
  79. Disable = Disable,
  80. Size = Vector3.new(10,10,10),
  81. DeathCheck = true
  82. }
  83.  
  84. local Players = cloneref(game:GetService("Players"))
  85. local RunService = cloneref(game:GetService("RunService"))
  86. local lp = Players.LocalPlayer
  87. local Run = true
  88. local Ignorelist = OverlapParams.new()
  89. Ignorelist.FilterType = Enum.RaycastFilterType.Include
  90.  
  91. local function getchar(plr)
  92. local plr = plr or lp
  93. return plr.Character
  94. end
  95.  
  96. local function gethumanoid(plr: Player | Character)
  97. local char = plr:IsA("Model") and plr or getchar(plr)
  98.  
  99. if char then
  100. return char:FindFirstChildWhichIsA("Humanoid")
  101. end
  102. end
  103.  
  104. local function IsAlive(Humanoid)
  105. return Humanoid and Humanoid.Health > 0
  106. end
  107.  
  108. local function GetTouchInterest(Tool)
  109. return Tool and Tool:FindFirstChildWhichIsA("TouchTransmitter",true)
  110. end
  111.  
  112. local function GetCharacters(LocalPlayerChar)
  113. local Characters = {}
  114. for i,v in Players:GetPlayers() do
  115. table.insert(Characters,getchar(v))
  116. end
  117. table.remove(Characters,table.find(Characters,LocalPlayerChar))
  118. return Characters
  119. end
  120.  
  121. local function Attack(Tool,TouchPart,ToTouch)
  122. if Tool:IsDescendantOf(workspace) then
  123. Tool:Activate()
  124. firetouchinterest(TouchPart,ToTouch,1)
  125. firetouchinterest(TouchPart,ToTouch,0)
  126. end
  127. end
  128.  
  129. table.insert(getgenv().configs.connections,Disable.Event:Connect(function()
  130. Run = false
  131. end))
  132.  
  133. while Run do
  134. local char = getchar()
  135. if IsAlive(gethumanoid(char)) then
  136. local Tool = char and char:FindFirstChildWhichIsA("Tool")
  137. local TouchInterest = Tool and GetTouchInterest(Tool)
  138.  
  139. if TouchInterest then
  140. local TouchPart = TouchInterest.Parent
  141. local Characters = GetCharacters(char)
  142. Ignorelist.FilterDescendantsInstances = Characters
  143. local InstancesInBox = workspace:GetPartBoundsInBox(TouchPart.CFrame,TouchPart.Size + getgenv().configs.Size,Ignorelist)
  144.  
  145. for i,v in InstancesInBox do
  146. local Character = v:FindFirstAncestorWhichIsA("Model")
  147.  
  148. if table.find(Characters,Character) then
  149. if getgenv().configs.DeathCheck then
  150. if IsAlive(gethumanoid(Character)) then
  151. Attack(Tool,TouchPart,v)
  152. end
  153. else
  154. Attack(Tool,TouchPart,v)
  155. end
  156. end
  157. end
  158. end
  159. end
  160. RunService.Heartbeat:Wait()
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement