Advertisement
mach10

Untitled

Apr 8th, 2025
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. --// Services
  2. local ReplicatedStorage = game:GetService('ReplicatedStorage');
  3. local Resources = require(ReplicatedStorage:WaitForChild('Resources'));
  4.  
  5. local Players = game:GetService('Players')
  6. local LocalPlayer = Players.LocalPlayer
  7.  
  8. --// Functions
  9. local RBLXTouched = {}
  10. RBLXTouched.__index = RBLXTouched
  11.  
  12. function RBLXTouched:Setup(Table : {})
  13.     if (Table) == nil or (string.lower(typeof(Table)) ~= 'table') then
  14.         return false
  15.     end
  16.  
  17.     setmetatable(Table, RBLXTouched)
  18.     return Table
  19. end
  20.  
  21. function RBLXTouched:IsTouchingBall()
  22.     if (self['Force'] == nil or string.lower(typeof(self['Force'])) ~= 'function') then
  23.         return false
  24.     end
  25.    
  26.     if (self['Limbs'] ~= nil and string.lower(typeof(self['Limbs'])) == 'table') and (LocalPlayer.Character ~= nil) then
  27.         local Character = LocalPlayer.Character
  28.         local GottenLimbs = {}
  29.        
  30.         for _, v in self['Limbs'] do
  31.             if (string.lower(typeof(v)) == 'string') then
  32.                 for i, x in Character:GetChildren() do
  33.                     if (x:IsA('Part') or x:IsA('BasePart')) then
  34.                         if (string.lower(x.Name) == string.lower(v)) then
  35.                             table.insert(GottenLimbs, x)
  36.                         end
  37.                     end
  38.                 end
  39.             end
  40.         end
  41.        
  42.         for _, v in GottenLimbs do
  43.             if (v:IsA('Part') or v:IsA('BasePart')) then
  44.                 for i, x in v:GetTouchingParts() do
  45.                     if (x.Parent == nil or x.Parent.Name ~= 'MACH') then
  46.                         continue
  47.                     elseif (x:GetAttribute('Anchored') == true) then
  48.                         continue
  49.                     end
  50.                    
  51.                     if (self['Forces'][1] ~= nil) then
  52.                         return task.spawn(function()
  53.                             self['Forces'][1](x, v.Name)
  54.                         end)
  55.                     end
  56.                     return
  57.                 end
  58.             end
  59.         end
  60.     end
  61.     return false
  62. end
  63.  
  64. function RBLXTouched:Start()
  65.     if (self['Forces'] == nil or string.lower(typeof(self['Forces'][1])) ~= 'function') then
  66.         return false
  67.     elseif (self['Limbs'] ~= nil and string.lower(typeof(self['Limbs'])) == 'table') and (LocalPlayer.Character ~= nil) then
  68.         local Character = LocalPlayer.Character
  69.         local GottenLimbs = {}
  70.  
  71.         for _, v in self['Limbs'] do
  72.             if (string.lower(typeof(v)) == 'string') then
  73.                 for i, x in Character:GetChildren() do
  74.                     if (x:IsA('Part') or x:IsA('BasePart')) then
  75.                         if (string.lower(x.Name) == string.lower(v)) then
  76.                             table.insert(GottenLimbs, x)
  77.                         end
  78.                     end
  79.                 end
  80.             end
  81.         end
  82.    
  83.         for _, v in GottenLimbs do
  84.             if (v:IsA('Part') or v:IsA('BasePart')) then
  85.                 v.Touched:Connect(function(Ball)
  86.                     if not (self['Kick']) then
  87.                         return false
  88.                     elseif (Ball.Parent ~= nil and Ball.Parent.Name == 'MACH') then
  89.                         if (Ball:GetAttribute('Anchored') == true) then
  90.                             return false
  91.                         end
  92.                        
  93.                         if (self['Forces'][1] ~= nil) then
  94.                             return coroutine.wrap(function()
  95.                                 return task.spawn(function()
  96.                                     self['Forces'][1](Ball, v.Name)
  97.                                 end)
  98.                             end)()
  99.                         end
  100.                     elseif (self['Shield'] ~= nil and self['Shield']) and (Ball.Name == 'Shield' and (string.lower(Ball.Parent.Name) ~= string.lower(LocalPlayer.Name))) then
  101.                         if (self['Forces'][2] ~= nil) then
  102.                             return coroutine.wrap(function()
  103.                                 return task.spawn(function()
  104.                                     self['Forces'][2]()
  105.                                 end)
  106.                             end)()
  107.                         end
  108.                     end
  109.                     return true
  110.                 end)
  111.             end
  112.         end
  113.     end
  114. end
  115.  
  116. return RBLXTouched
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement