Combo moves happening at once and having to go near a person to click to attack

I have two problems with the script here:

  1. When I click, it plays for of the moves at once, but I want to be able to click and it will only play the move allocated to that mouse click. i.e. Click mouse once, play animation1. Click mouse again, play animation2 and so on.

  2. This only activates when I’m near a person if I click. I want to be able to click to attack wherever I please without having to go near a person

This is where I think the problem resides in.

for i,v in pairs(game.Workspace:GetChildren())do
			local m = (v:IsA("Model")and v) or nil
				if m and m:FindFirstChild("HumanoidRootPart") and m:FindFirstChild("HumanoidRootPart") and m ~=Char then
					if (Char.HumanoidRootPart.Position - m.HumanoidRootPart.Position).magnitude <= 6 then
						if not db and Combo == 1 then
							Cand = true
							c1:Play()
							local Dmg = Char["Part"]:Clone()
							Dmg.Parent = Char["Part"]
							Dmg.Anchored = false
							Dmg.CanCollide = false
							m.Humanoid:TakeDamage(math.random(1,30))
							wait(0.5)
							Cand = false
							Dmg:Destroy()
							Combo = Combo + 1
							print(Combo)
						
						
						if Combo == 2 then
							Cand = true
							c2:Play()
							local Dmg = Char["Part"]:Clone()
							Dmg.Parent = Char["Part"]
							Dmg.Anchored = false
							Dmg.CanCollide = false
							m.Humanoid:TakeDamage(math.random(1,30))
							wait(0.5)
							Cand = false
							Dmg:Destroy()
							Combo = Combo + 1
							print(Combo)
						end
						
						 if Combo == 3 then
							Cand = true
							c3:Play()
							local Dmg = Char["Part"]:Clone()
							Dmg.Parent = Char["Part"]
							Dmg.Anchored = false
							Dmg.CanCollide = false
							m.Humanoid:TakeDamage(math.random(1,30))
							wait(0.5)
							Cand = false
							Dmg:Destroy()
							Combo = Combo + 1
							print(Combo)
						end
						
						if Combo == 4 then
							Cand = true
							c4:Play()
							local Dmg = Char["Part"]:Clone()
							Dmg.Parent = Char["Part"]
							Dmg.Anchored = false
							Dmg.CanCollide = false
							m.Humanoid:TakeDamage(math.random(1,30))
							wait(0.5)
							Cand = false
							Dmg:Destroy()
							Combo = Combo + 1
							print(Combo)
						end
						if Combo == 5 then
							Cand = true
							c5:Play()
							local Dmg = Char["Part"]:Clone()
							Dmg.Parent = Char["Part"]
							Dmg.Anchored = false
							Dmg.CanCollide = false
							wait(0.5)
							Cand = false
							Dmg:Destroy()
							m.Humanoid:TakeDamage(100)
							Combo = 1
						end
					end
				end
			end
		end
1 Like

The way your script is written is that it checks if there’s a player near you, THEN it’ll play an animation.
You have to rewrite it so the damage handling & animations is seperated.

1 Like

I rewrote it and solved issue 2. I apologise if I sound impatient or rude, but I’d like an answer for issue 1.

For that, you can use tick() to determine if the players are doing combos or not (pressing mouse x times within x seconds)

will edit my reply later when I’ve wrote proper example code

So if you were creating a combat system you have to make separate animations instead of creating one long animation while using events to mark each stage of the click attack?

(I’d assume. I know nothing about scripting… :sweat_smile:)