I have two problems with the script here:
-
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.
-
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