Anukun_Lucifer

SwordComboServer

Aug 16th, 2025
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | Gaming | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local SwordHitEvent = ReplicatedStorage:WaitForChild("SwordHitEvent")
  3.  
  4. local function flashRed(model)
  5.     -- สร้าง Highlight สีแดง
  6.     local highlight = Instance.new("Highlight")
  7.     highlight.Adornee = model
  8.     highlight.FillColor = Color3.new(1, 0, 0)
  9.     highlight.OutlineColor = Color3.new(1, 0, 0)
  10.     highlight.FillTransparency = 0.5
  11.     highlight.OutlineTransparency = 0
  12.     highlight.Parent = model
  13.  
  14.     -- กระพริบ Highlight
  15.     for k, i in highlight:GetChildren() do end -- No children, just placeholder
  16.  
  17.     for i = 1, 3 do
  18.         highlight.Enabled = true
  19.         task.wait(0.07)
  20.         highlight.Enabled = false
  21.         task.wait(0.07)
  22.     end
  23.  
  24.     -- ลบ Highlight หลังจบ
  25.     highlight:Destroy()
  26. end
  27.  
  28. local function playDamageSound(player)
  29.     -- Find the equipped tool in the player's character
  30.     local character = player.Character
  31.     if character then
  32.         for k, child in character:GetChildren() do
  33.             if child:IsA("Tool") then
  34.                 local handle = child:FindFirstChild("Handle")
  35.                 if handle then
  36.                     local sound = handle:FindFirstChild("DamageSound")
  37.                     if sound then
  38.                         sound:Play()
  39.                     end
  40.                 end
  41.             end
  42.         end
  43.     end
  44. end
  45.  
  46. local function knockback(model, hitPos, attackerPos)
  47.     for k, part in model:GetChildren() do
  48.         if part:IsA("BasePart") then
  49.             local direction = (part.Position - attackerPos).Unit
  50.             part.AssemblyLinearVelocity = direction * 50 -- 1 stud knockback
  51.         end
  52.     end
  53. end
  54.  
  55. SwordHitEvent.OnServerEvent:Connect(function(player, enemyModel, damage, hitPos)
  56.     local humanoid = enemyModel:FindFirstChildOfClass("Humanoid")
  57.     if humanoid and humanoid.Health > 0 then
  58.         humanoid:TakeDamage(damage)
  59.         playDamageSound(player)
  60.         knockback(enemyModel, hitPos, player.Character and player.Character:GetPivot().Position or hitPos)
  61.         flashRed(enemyModel)
  62.     end
  63. end)
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment