Advertisement
dv3v

Server script

Oct 18th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. --------------------
  2. -------------------- Variables
  3.  
  4. local tool = script.Parent.Parent
  5. local player = tool.Parent.Parent
  6. local character = player.Character or player.CharacterAdded:Wait()
  7. local remoteEvent = tool:WaitForChild("remote_event")
  8.  
  9. --------------------
  10. -------------------- Functions
  11.  
  12. function HasWeapon(humanoid)
  13.     local descendants = humanoid.Parent:GetDescendants()
  14.     for _, v in pairs(descendants) do
  15.         if v:IsA("Tool") then
  16.             if v:FindFirstChild("blade") then
  17.                 return v
  18.             end
  19.         end
  20.     end
  21.     return nil
  22. end
  23.  
  24. --------------------
  25. -------------------- Weapon Actions
  26.  
  27. remoteEvent.OnServerEvent:Connect(function(player, func, value)
  28.    
  29.     ----------
  30.     ---------- Block
  31.    
  32.     if func == "Block" then
  33.         tool.Status.blocking.Value = value
  34.         return
  35.     end
  36.    
  37.     ----------
  38.     ---------- Attack
  39.    
  40.     if func == "Attack" then
  41.         local humanoid = value
  42.         local weapon = HasWeapon(humanoid)
  43.         if weapon ~= nil then
  44.             print("Has weapon out")
  45.             if weapon.Status.blocking.Value == false then
  46.                 humanoid:TakeDamage(10)
  47.             else
  48.                 print("blocking")
  49.             end
  50.             return
  51.         end
  52.         humanoid:TakeDamage(10)
  53.         return
  54.     end
  55.    
  56.     ----------
  57.     ---------- Stun
  58.    
  59.     if func == "Stun" then
  60.         tool.Status.stunning.Value = value
  61.         return
  62.     end
  63.    
  64.     ----------
  65.     ----------
  66.    
  67.     error("Function: '" .. func .. "' not found.") -- Called function was not found
  68. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement