Advertisement
BoblokDevelopyyyr

HandleDamageServer

Jun 7th, 2025
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local RS = game:GetService("ReplicatedStorage")
  2. local events = RS.Events
  3. local dealDamageEvent = events.DealDamage
  4. local module = require(game.ServerScriptService.Stats)
  5. local dmg = 0
  6.  
  7. dealDamageEvent.OnServerEvent:Connect(function(player)
  8.     local character = player.Character or player.CharacterAdded:Wait()
  9.     local humanoid = character:FindFirstChildOfClass("Humanoid")
  10.     local arm = character:FindFirstChild("Right Arm")::BasePart
  11.    
  12.     for _, child in ipairs(character:GetChildren()) do
  13.         if child:IsA("Tool") then
  14.             print(child.Name)
  15.             print(module[child.Name])
  16.             dmg = module[child.Name]
  17.         end
  18.     end
  19.  
  20.     local db = false
  21.  
  22.         arm.Touched:Connect(function(hitObject)
  23.             if not db then
  24.                 local hitHum = hitObject.Parent:FindFirstChildOfClass("Humanoid")
  25.                 if hitHum then
  26.                     hitHum:TakeDamage(dmg)
  27.                     db = true
  28.  
  29.                 else
  30.                     db = true
  31.                 end
  32.             end
  33.         end)
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement