#can someone help?

49 messages · Page 1 of 1 (latest)

grim flower
#

im trying to make a combo script, yes it is AI

raven sinew
grim flower
#

Where did it go

#

Oh

#

What

#

Where is it

#

@raven sinew

topaz atlas
#

are you missing an end at the bottom or did you not copy it in

plain plover
#

Please use pastebin, wdym .txt

raven sinew
#
-- 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

grim flower
#

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?

rose goblet
#

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

grim flower
#

Someone else told me that, where should it be?

#

Ohh

rose goblet
#

after each entry

grim flower
#

punch_anims,[combo]
?

rose goblet
#

no

grim flower
#

This is my first time scripting

rose goblet
#

commas are used to separate values in a table

grim flower
#

Don't judge

#

Ohh

#

Like maths

#

Kinda

rose goblet
#

sure

#

0,0,0

#

or anim1,anim2,anim3

grim flower
#

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

rose goblet
#

press insert on your keyboard

grim flower
#

Huh?

rose goblet
grim flower
#

ohhh

sinful craneBOT
#

studio** You are now Level 5! **studio