#Damage For Punch Animation
7 messages · Page 1 of 1 (latest)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Replace this with the actual Animation ID or the asset's name if stored in ReplicatedStorage
local animationId = "rbxassetid://112690042981985"
-- Cooldown duration in seconds
local cooldownTime = 1.5
local lastClicked = 0 -- Time of the last click
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
-- Ignore if the input was already processed (e.g., UI or chat input)
if gameProcessedEvent then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- Left mouse button click
local currentTime = tick() -- Get the current time
-- Check if the cooldown period has passed
if currentTime - lastClicked >= cooldownTime then
local player = game.Players.LocalPlayer
local character = player and player.Character
if character and character:FindFirstChild("Humanoid") then
local humanoid = character.Humanoid
-- Create an animation instance using the animation ID
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
-- Update lastClicked time to prevent another click until the cooldown is over
lastClicked = currentTime
end
else
-- Optionally, you can give feedback to the player about the cooldown, e.g.:
print("Please wait for the cooldown to finish.")
end
end
end)
so like what did you try
i tried creating a hitbox and when another player touches it does damage
nothing about that code creates a hitbox
** You are now Level 1! **