#can someone help?
49 messages · Page 1 of 1 (latest)
are you missing an end at the bottom or did you not copy it in
Please use pastebin, wdym .txt
-- Punch Combo Script for Roblox (no tool, just animations & damage)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animationController = humanoid:WaitForChild("Animator")
local punchAnimations = {
"135887565035838", -- Punch 1
"71427803477064", -- Punch 2
"132574833133435", -- Punch 3
"131422192145418" -- Punch 4
}
local punchComboTimeLimit = 2 -- seconds
local maxCombos = 4
local currentCombo = 1
local lastPunchTime = 0
local isPunching = false
local damageAmount = 3 -- Amount of damage for each punch
-- Function to play animation
local function playPunchAnimation(animationId)
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. animationId
local animationTrack = animationController:LoadAnimation(animation)
animationTrack:Play()
return animationTrack
end
-- Function to deal damage
local function dealDamage()
-- Get the nearest enemy to deal damage to
local enemies = game.Workspace:GetChildren()
for _, enemy in ipairs(enemies) do
if enemy:IsA("Model") and enemy:FindFirstChild("Humanoid") and enemy.Humanoid.Health > 0 then
-- If it's an enemy (any model with a humanoid), apply damage
local distance = (enemy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude
if distance < 10 then -- If within range (you can adjust the range)
enemy.Humanoid:TakeDamage(damageAmount)
end
end
end
end
-- Function to handle the punching logic
local function onPunch()
local currentTime = tick()
-- If it's too soon after the last punch, ignore it
if currentTime - lastPunchTime < punchComboTimeLimit then
-- If they are still in the combo window, proceed
if currentCombo <= maxCombos then
local animationTrack = playPunchAnimation(punchAnimations[currentCombo])
animationTrack.Stopped:Wait() -- Wait until the animation ends
dealDamage() -- Deal damage when the animation completes
currentCombo = currentCombo + 1
end
else
-- Reset combo if combo window expired
currentCombo = 1
local animationTrack = playPunchAnimation(punchAnimations[currentCombo])
animationTrack.Stopped:Wait() -- Wait until the animation ends
dealDamage() -- Deal damage for the first punch
end
there
now its slightly more readable
I redid the script to make it easier
To make a combo
Without AI this time
I was learning from developer forum
Why doesn't it work?
missing commas in punch_anims
also you referenced it as punchanims in the script but the table is punch_anims
you should always code with the output open
after each entry
punch_anims,[combo]
?
no
This is my first time scripting
commas are used to separate values in a table
Also
There is this black square
On everywhere where I click
On the script
And when I try typw
It removes everything in front of it
Thank you so much
It works now
press insert on your keyboard
Huh?
this
ohhh
** You are now Level 5! **