Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make this punch script deal damage?

I don't know how to make this script deal damage, it's suppose to be a punch can someone help me out

-- Fixed by Meme  Colocal player = game.players.LocalPlayer 
local db = true
local damaged = false

local anim = Instance.new("Animation")
anim.AnimationId = "https://www.roblox.com/asset/?id=4804852252"


game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") and not db and not damaged and hit.Parent.Humanoid ~= game.Players.LocalPlayer.Character.Humanoid then
  game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
 end
end)
game:GetService("UserInputService").InputBegan:Connect(function(input, event)
 if input.KeyCode == Enum.KeyCode.T and db then
  db = false
  local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(anim)
  playAnim:Play()
  wait(2)
  damaged = false
  db = true
  end
end)

1 comment

0

Please format your code and let us see your server sided code.

1 answer

✓ Accepted answer

Since you don't actually show the server script, I'll make it for you

game.ReplicatedStorage.Punch.OnServerEvent:Connect(function(plr, humanoid)
humanoid:TakeDamage(20) -- Change 20 to the amount of damage you want it to deal
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.