Advertisement
WAOKyoNaga

Hit Box

Jul 5th, 2019 (edited)
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. uis = game:GetService("UserInputService")
  2. cg = game:GetService("CoreGui")
  3. sg = game:GetService("StarterGui")
  4. wp = game:GetService("Workspace")
  5. cmr = wp.Camera
  6. rs = game:GetService("ReplicatedStorage")
  7. rsd = game:GetService("RunService").RenderStepped
  8. lgt = game:GetService("Lighting")
  9. plrs = game:GetService("Players")
  10. lplr = plrs.LocalPlayer
  11. mouse = lplr:GetMouse()
  12. virtualUser = game:GetService("VirtualUser")
  13.  
  14. if _G.hitBoxSize == nil then
  15.     _G.hitBoxSize = {3, 3, 3}
  16.     _G.hitBoxBody = "Head"
  17.     _G.hitBoxColor = "Really blue"
  18.     _G.hitBoxTransparency = 0.9
  19. -- HumanoidRootPart
  20. end
  21.  
  22. function createHitBox(parent)
  23.     local sizeBody = parent.Character[_G.hitBoxBody].Size.x
  24.     parent.Character[_G.hitBoxBody].Size = Vector3.new(_G.hitBoxSize[1], _G.hitBoxSize[2], _G.hitBoxSize[3])
  25.     parent.Character[_G.hitBoxBody].Transparency = _G.hitBoxTransparency
  26.     parent.Character[_G.hitBoxBody].BrickColor = BrickColor.new(_G.hitBoxColor)
  27.     parent.Character[_G.hitBoxBody].Material = "Neon"
  28.     parent.Character[_G.hitBoxBody].CanCollide = false
  29.  
  30.     parent.Character[_G.hitBoxBody].Changed:connect(
  31.         function(property)
  32.             wait(0.1)
  33.             if property == "Size" or property == "CanCollide" then
  34.                 parent.Character[_G.hitBoxBody].Size = Vector3.new(_G.hitBoxSize[1], _G.hitBoxSize[2], _G.hitBoxSize[3])
  35.                 parent.Character[_G.hitBoxBody].CanCollide = false
  36.             end
  37.         end
  38.     )
  39. end
  40.  
  41. function hitBox()
  42.     for _, o in pairs(plrs:GetPlayers()) do
  43.         if o.Name ~= lplr.Name then
  44.             o.CharacterAdded:Connect(
  45.                 function(characterModel)
  46.                     if characterModel:WaitForChild(_G.hitBoxBody) then
  47.                         wait(0.5)
  48.                         createHitBox(o)
  49.                     end
  50.                 end
  51.             )
  52.         end
  53.     end
  54.  
  55.     plrs.PlayerAdded:Connect(
  56.         function(newPlayer)
  57.             newPlayer.CharacterAdded:Connect(
  58.                 function(characterModel)
  59.                     if characterModel:WaitForChild(_G.hitBoxBody) then
  60.                         wait(0.5)
  61.                         createHitBox(newPlayer)
  62.                     end
  63.                 end
  64.             )
  65.         end
  66.     )
  67.  
  68.     for _, o in pairs(plrs:GetPlayers()) do
  69.         if o.Name ~= lplr.Name then
  70.             spawn(
  71.                 function()
  72.                     if o.Character:FindFirstChild(_G.hitBoxBody) then
  73.                         wait(0.1)
  74.                         createHitBox(o)
  75.                     end
  76.                 end
  77.             )
  78.         end
  79.     end
  80. end
  81. hitBox()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement