Advertisement
EzSscripts

Sword Reach Script

Jun 24th, 2022 (edited)
5,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.69 KB | None | 0 0
  1. ---EzScripts on youtube
  2.  
  3.  
  4. local active = true
  5. local trueActive = true
  6. local reachType = "Sphere"
  7. local dmgEnabled = true
  8. local visualizerEnabled = false
  9.  
  10. local visualizer = Instance.new("Part")
  11. visualizer.BrickColor = BrickColor.Blue()
  12. visualizer.Transparency = 0.6
  13. visualizer.Anchored = true
  14. visualizer.CanCollide = false
  15. visualizer.Size = Vector3.new(0.5,0.5,0.5)
  16. visualizer.BottomSurface = Enum.SurfaceType.Smooth
  17. visualizer.TopSurface = Enum.SurfaceType.Smooth
  18.  
  19. local ScreenGui = Instance.new("ScreenGui")
  20. local Frame = Instance.new("Frame")
  21. local TextLabel = Instance.new("TextLabel")
  22. local TextBox = Instance.new("TextBox")
  23. local TextLabel_2 = Instance.new("TextLabel")
  24. local TextLabel_3 = Instance.new("TextLabel")
  25. local TextLabel_4 = Instance.new("TextLabel")
  26. local TextButton = Instance.new("TextButton")
  27. local Frame_2 = Instance.new("Frame")
  28. local Frame_3 = Instance.new("Frame")
  29. local Frame_4 = Instance.new("Frame")
  30. local Frame_5 = Instance.new("Frame")
  31. local TextButton_2 = Instance.new("TextButton")
  32.  
  33. --Properties:
  34.  
  35. ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  36. ScreenGui.DisplayOrder = 999999999
  37. ScreenGui.ResetOnSpawn = false
  38.  
  39. Frame.Parent = ScreenGui
  40. Frame.AnchorPoint = Vector2.new(0, 0.5)
  41. Frame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  42. Frame.BackgroundTransparency = 0.300
  43. Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
  44. Frame.BorderSizePixel = 4
  45. Frame.Position = UDim2.new(0, 0, 0.600000024, 0)
  46. Frame.Size = UDim2.new(0.150000006, 0, 0.300000012, 0)
  47.  
  48. TextLabel.Parent = Frame
  49. TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  50. TextLabel.BackgroundTransparency = 1.000
  51. TextLabel.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
  52. TextLabel.Font = Enum.Font.SourceSans
  53. TextLabel.Text = "Reach:"
  54. TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  55. TextLabel.TextScaled = true
  56. TextLabel.TextSize = 14.000
  57. TextLabel.TextWrapped = true
  58.  
  59. TextBox.Parent = Frame
  60. TextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  61. TextBox.BackgroundTransparency = 1.000
  62. TextBox.Position = UDim2.new(0.600000024, 0, 0, 0)
  63. TextBox.Size = UDim2.new(0.400000006, 0, 0.200000003, 0)
  64. TextBox.Font = Enum.Font.SourceSans
  65. TextBox.Text = "3.5"
  66. TextBox.TextColor3 = Color3.fromRGB(255, 76, 76)
  67. TextBox.TextScaled = true
  68. TextBox.TextSize = 14.000
  69. TextBox.TextWrapped = true
  70.  
  71. TextLabel_2.Parent = Frame
  72. TextLabel_2.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  73. TextLabel_2.BackgroundTransparency = 1.000
  74. TextLabel_2.Position = UDim2.new(0, 0, 0.200000003, 0)
  75. TextLabel_2.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
  76. TextLabel_2.Font = Enum.Font.SourceSans
  77. TextLabel_2.Text = "Shape:"
  78. TextLabel_2.TextColor3 = Color3.fromRGB(255, 255, 255)
  79. TextLabel_2.TextScaled = true
  80. TextLabel_2.TextSize = 14.000
  81. TextLabel_2.TextWrapped = true
  82.  
  83. TextLabel_3.Parent = Frame
  84. TextLabel_3.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  85. TextLabel_3.BackgroundTransparency = 1.000
  86. TextLabel_3.Position = UDim2.new(0, 0, 0.400000006, 0)
  87. TextLabel_3.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
  88. TextLabel_3.Font = Enum.Font.SourceSans
  89. TextLabel_3.Text = "Damage:"
  90. TextLabel_3.TextColor3 = Color3.fromRGB(255, 255, 255)
  91. TextLabel_3.TextScaled = true
  92. TextLabel_3.TextSize = 14.000
  93. TextLabel_3.TextWrapped = true
  94.  
  95. TextLabel_4.Parent = Frame
  96. TextLabel_4.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  97. TextLabel_4.BackgroundTransparency = 1.000
  98. TextLabel_4.Position = UDim2.new(0, 0, 0.600000024, 0)
  99. TextLabel_4.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
  100. TextLabel_4.Font = Enum.Font.SourceSans
  101. TextLabel_4.Text = "Visualizer:"
  102. TextLabel_4.TextColor3 = Color3.fromRGB(255, 255, 255)
  103. TextLabel_4.TextScaled = true
  104. TextLabel_4.TextSize = 14.000
  105. TextLabel_4.TextWrapped = true
  106.  
  107. TextButton.Parent = Frame
  108. TextButton.AnchorPoint = Vector2.new(0, 1)
  109. TextButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  110. TextButton.BackgroundTransparency = 1.000
  111. TextButton.Position = UDim2.new(0, 0, 1, 0)
  112. TextButton.Size = UDim2.new(1, 0, 0.150000006, 0)
  113. TextButton.Font = Enum.Font.SourceSansBold
  114. TextButton.Text = "Kill Script"
  115. TextButton.TextColor3 = Color3.fromRGB(222, 0, 0)
  116. TextButton.TextScaled = true
  117. TextButton.TextSize = 14.000
  118. TextButton.TextWrapped = true
  119.  
  120. Frame_2.Parent = Frame
  121. Frame_2.Active = true
  122. Frame_2.AnchorPoint = Vector2.new(0, 0.5)
  123. Frame_2.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
  124. Frame_2.BorderSizePixel = 0
  125. Frame_2.Position = UDim2.new(0.725000024, 0, 0.699999988, 0)
  126. Frame_2.Size = UDim2.new(0, 25, 0, 25)
  127. Frame_2.ZIndex = 5
  128.  
  129. Frame_3.Parent = Frame_2
  130. Frame_3.AnchorPoint = Vector2.new(0.5, 0.5)
  131. Frame_3.BackgroundColor3 = Color3.fromRGB(255, 76, 76)
  132. Frame_3.BorderSizePixel = 0
  133. Frame_3.LayoutOrder = 1
  134. Frame_3.Position = UDim2.new(0.5, 0, 0.5, 0)
  135.  
  136. Frame_4.Parent = Frame
  137. Frame_4.Active = true
  138. Frame_4.AnchorPoint = Vector2.new(0, 0.5)
  139. Frame_4.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
  140. Frame_4.BorderSizePixel = 0
  141. Frame_4.Position = UDim2.new(0.725000024, 0, 0.5, 0)
  142. Frame_4.Size = UDim2.new(0, 25, 0, 25)
  143. Frame_4.ZIndex = 5
  144.  
  145. Frame_5.Parent = Frame_4
  146. Frame_5.AnchorPoint = Vector2.new(0.5, 0.5)
  147. Frame_5.BackgroundColor3 = Color3.fromRGB(255, 76, 76)
  148. Frame_5.BorderSizePixel = 0
  149. Frame_5.LayoutOrder = 1
  150. Frame_5.Position = UDim2.new(0.5, 0, 0.5, 0)
  151. Frame_5.Size = UDim2.new(1, 0, 1, 0)
  152.  
  153. TextButton_2.Parent = Frame
  154. TextButton_2.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  155. TextButton_2.BackgroundTransparency = 1.000
  156. TextButton_2.Position = UDim2.new(0.600000024, 0, 0.200000003, 0)
  157. TextButton_2.Size = UDim2.new(0.400000006, 0, 0.200000003, 0)
  158. TextButton_2.Font = Enum.Font.SourceSans
  159. TextButton_2.Text = "Sphere"
  160. TextButton_2.TextColor3 = Color3.fromRGB(255, 76, 76)
  161. TextButton_2.TextScaled = true
  162. TextButton_2.TextSize = 14.000
  163. TextButton_2.TextWrapped = true
  164.  
  165. repeat wait() until game.Players.LocalPlayer
  166. ScreenGui.Parent = game:GetService("CoreGui")
  167.  
  168.  
  169.  
  170. Frame_4.InputBegan:connect(function(inp)
  171. if inp.UserInputType == Enum.UserInputType.MouseButton1 then
  172. dmgEnabled = not dmgEnabled
  173. local goal = {Size = UDim2.new(0,0,0,0)}
  174. if dmgEnabled then
  175. goal = {Size = UDim2.new(1,0,1,0)}
  176. end
  177. game:GetService("TweenService"):Create(Frame_5,TweenInfo.new(0.12,Enum.EasingStyle.Quad),goal):Play()
  178. end
  179. end)
  180. Frame_2.InputBegan:connect(function(inp)
  181. if inp.UserInputType == Enum.UserInputType.MouseButton1 then
  182. visualizerEnabled = not visualizerEnabled
  183. local goal = {Size = UDim2.new(0,0,0,0)}
  184. if visualizerEnabled then
  185. goal = {Size = UDim2.new(1,0,1,0)}
  186. end
  187. game:GetService("TweenService"):Create(Frame_3,TweenInfo.new(0.12,Enum.EasingStyle.Linear),goal):Play()
  188. end
  189. end)
  190. TextButton_2.MouseButton1Click:connect(function()
  191. if reachType == "Sphere" then
  192. reachType = "Line"
  193. else
  194. reachType = "Sphere"
  195. end
  196. TextButton_2.Text = reachType
  197. end)
  198. TextButton.MouseButton1Click:connect(function()
  199. trueActive = false
  200. ScreenGui:Destroy()
  201. end)
  202. game:GetService("UserInputService").InputBegan:connect(function(inp,gpe)
  203. if gpe then return end
  204. if inp.KeyCode == Enum.KeyCode.H then
  205. ScreenGui.Enabled = not ScreenGui.Enabled
  206. end
  207. end)
  208.  
  209. local plr = game.Players.LocalPlayer
  210.  
  211. local function onHit(hit,handle)
  212. local victim = hit.Parent:FindFirstChildOfClass("Humanoid")
  213. if victim and victim.Parent.Name ~= game.Players.LocalPlayer.Name then
  214. if dmgEnabled then
  215. for _,v in pairs(hit.Parent:GetChildren()) do
  216. if v:IsA("Part") then
  217. firetouchinterest(v,handle,0)
  218. firetouchinterest(v,handle,1)
  219. end
  220. end
  221. else
  222. firetouchinterest(hit,handle,0)
  223. firetouchinterest(hit,handle,1)
  224. end
  225. end
  226. end
  227.  
  228. local function getWhiteList()
  229. local wl = {}
  230. for _,v in pairs(game.Players:GetPlayers()) do
  231. if v ~= plr then
  232. local char = v.Character
  233. if char then
  234. for _,q in pairs(char:GetChildren()) do
  235. if q:IsA("Part") then
  236. table.insert(wl,q)
  237. end
  238. end
  239. end
  240. end
  241. end
  242. return wl
  243. end
  244.  
  245. game:GetService("RunService").RenderStepped:connect(function()
  246. if not active or not trueActive then return end
  247. local s = plr.Character and plr.Character:FindFirstChildOfClass("Tool")
  248. if not s then visualizer.Parent = nil end
  249. if s then
  250. local handle = s:FindFirstChild("Handle") or s:FindFirstChildOfClass("Part")
  251. if handle then
  252. if visualizerEnabled then
  253. visualizer.Parent = workspace
  254. else
  255. visualizer.Parent = nil
  256. end
  257. local reach = tonumber(TextBox.Text)
  258. if reach then
  259. if reachType == "Sphere" then
  260. visualizer.Shape = Enum.PartType.Ball
  261. visualizer.Size = Vector3.new(reach,reach,reach)
  262. visualizer.CFrame = handle.CFrame
  263. for _,v in pairs(game.Players:GetPlayers()) do
  264. local hrp = v.Character and v.Character:FindFirstChild("HumanoidRootPart")
  265. if hrp and handle then
  266. local mag = (hrp.Position-handle.Position).magnitude
  267. if mag <= reach then
  268. onHit(hrp,handle)
  269. end
  270. end
  271. end
  272. elseif reachType == "Line" then
  273. local origin = (handle.CFrame*CFrame.new(0,0,-2)).p
  274. local ray = Ray.new(origin,handle.CFrame.lookVector*-reach)
  275. local p,pos = workspace:FindPartOnRayWithWhitelist(ray,getWhiteList())
  276. visualizer.Shape = Enum.PartType.Block
  277. visualizer.Size = Vector3.new(1,0.8,reach)
  278. visualizer.CFrame = handle.CFrame*CFrame.new(0,0,(reach/2)+2)
  279. if p then
  280. onHit(p,handle)
  281. else
  282. for _,v in pairs(handle:GetTouchingParts()) do
  283. onHit(v,handle)
  284. end
  285. end
  286. end
  287. end
  288. end
  289. end
  290. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement