-
What do you want to achieve? I want to create a counterattack move.
-
What is the issue? When attacked during the counter, a “cutscene”~ish counter does not come up.
-
What solutions have you tried so far? I have not used any solutions so far, I’m asking for one. I’m currently using boolvalues, and I changed all health-related scripts to check if the player currently has the
Counterboolvalue.
https://gyazo.com/dede93cf80518bf35c55ad29b9453def – video showing how it doesn’t work
SERVERSCRIPT
attack.OnServerEvent:Connect(function(plr,input,hit,hum)
local c = plr.Character
local hrp = c.HumanoidRootPart
local hrpPos = hrp.Position
if input == Enum.KeyCode.X then
local plrhum = c.Humanoid
plrhum.Health += hit
local slash = {
slaaash = "rbxassetid://4908078635";
normal = "rbxassetid://7095815780";
normal2 = "rbxassetid://4958430453";
normal3 = "rbxassetid://8680211166";
echo = "rbxassetid://4958427918";
normal4 = "rbxassetid://220833967";
normal5 = "rbxassetid://220834000";
normal6 = "rbxassetid://220834019";
normal7 = "rbxassetid://220833976";
normal8 = "rbxassetid://7545764969";
normal9 = "rbxassetid://8971633315";
normal10 = "rbxassetid://5101395394";
normal11 = "rbxassetid://5989945551";
normal12 = "rbxassetid://7380966103";
normal13 = "rbxassetid://7219442932";
}
local xanim2 = plrhum:LoadAnimation(rs.Anims.X.Part2)
local contents = c:FindFirstChild("Damager").Value
print(contents)
local victim = workspace:FindFirstChild(contents)
xanim2:Play()
victimized:FireAllClients(victim)
local victimHum = victim:FindFirstChildWhichIsA("Humanoid")
local victimhrp = victim:FindFirstChild("HumanoidRootPart")
local xconnection2
xconnection2 = xanim2.KeyframeReached:Connect(function(kfname)
statuseffects.Stun(c,victim,8)
if kfname == "StartAnim" then
plrhum.WalkSpeed = 0
plrhum.AutoRotate = false
victimHum.AutoRotate = false
hrp.CFrame = CFrame.new(hrp.Position, Vector3.new(victimhrp.Position.X,hrp.Position.Y,victimhrp.Position.Z))
victimhrp.CFrame = hrp.CFrame * CFrame.new(0,0,-5)
victimhrp.CFrame = CFrame.new(victimhrp.Position, Vector3.new(hrp.Position.X, victimhrp.Position.Y, hrp.Position.Z))
elseif kfname == "Throw" then
local tweenHRP = ts:Create(victimhrp, TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0), {CFrame = victimhrp.CFrame * CFrame.new(0,10,0)})
local tweenHRP2 = ts:Create(hrp,TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0),{CFrame = hrp.CFrame * CFrame.new(0,10,0)})
tweenHRP:Play()
victimHum:TakeDamage(5)
local connection2
local function tweenCompleted()
victimhrp.Anchored = true
tweenHRP2:Play()
connection2:Disconnect()
end
local connection3
local function tweenCompleted2()
hrp.Anchored = true
connection3:Disconnect()
end
connection2 = tweenCompleted
connection3 = tweenCompleted2
elseif kfname == "StartWindup" then
local thunder = counterparticles.ExtraThunder:Clone()
thunder.Parent = plrhum.BodyFrontAttachment
elseif kfname == "EndWindup" then
local slash = counterparticles.Slash:Clone()
slash.Parent = plrhum.BodyFrontAttachment
elseif kfname == "FirstAttack" then
local sound = slash[math.random(1,#slash)]
local soundobject = Instance.new("Sound")
soundobject.Parent = victimhrp
soundobject.SoundId = sound
soundobject.Volume = 5
soundobject:Play()
victimHum:TakeDamage(10)
elseif kfname == "2ndAttack" then
local sound = slash[math.random(1,#slash)]
local soundobject = Instance.new("Sound")
soundobject.Parent = victimhrp
soundobject.SoundId = sound
soundobject.Volume = 5
soundobject:Play()
victimHum:TakeDamage(15)
elseif kfname == "3rdAttack" then
local sound = slash[math.random(1,#slash)]
local soundobject = Instance.new("Sound")
soundobject.Parent = victimhrp
soundobject.SoundId = sound
soundobject.Volume = 5
soundobject:Play()
victimHum:TakeDamage(15)
elseif kfname == "4thAttack" then
local sound = slash[math.random(1,#slash)]
local soundobject = Instance.new("Sound")
soundobject.Parent = victimhrp
soundobject.SoundId = sound
soundobject.Volume = 5
soundobject:Play()
victimHum:TakeDamage(15)
elseif kfname == "FinalAttack" then
local sound = slash["echo"]
local soundobject = Instance.new("Sound")
soundobject.Parent = victimhrp
soundobject.SoundId = sound
soundobject.Volume = 5
soundobject:Play()
victimHum:TakeDamage(25)
local tweenHRP = ts:Create(victimhrp, TweenInfo.new(1,Enum.EasingStyle.Quad, Enum.EasingDirection.In,0,false,0), {CFrame = victimhrp.CFrame * CFrame.new(0,0,0)})
tweenHRP:Play()
victimhrp.Anchored = false
hrp.Anchored = false
plrhum.AutoRotate = true
victimHum.AutoRotate = true
plrhum.WalkSpeed = 16
end
end)
end
end)
fAttack.OnServerEvent:Connect(function(plr,input)
local c = plr.Character
local phum = c:FindFirstChild("Humanoid")
if input == Enum.KeyCode.X then
local xanim = phum:LoadAnimation(rs.Anims.x.Part1)
xanim:Play()
local counterval = Instance.new("BoolValue")
local xconnection
xconnection = xanim.KeyframeReached:Connect(function(kfname)
if kfname == "StartAnim" then
phum.WalkSpeed = 3
elseif kfname == "StartCounter" then
phum.WalkSpeed = 3
counterval.Parent = c
counterval.Name = "Counter"
elseif kfname == "EndCounter" then
statuseffects.SelfStun(c,1)
counterval:Destroy()
elseif kfname == "EndAnim" then
phum.WalkSpeed = 16
xconnection:Disconnect()
end
end)
end
end)
LOCAL SCRIPT
local currentHealth = hum.Health
hum.HealthChanged:Connect(function(health)
if health < currentHealth and hum:GetState() ~= Enum.HumanoidStateType.Dead then
if c:FindFirstChild("Counter") then
local counter = c:FindFirstChild("Counter")
if counter:IsA("IntValue") then
local HealthDifference = currentHealth - health
attack:FireServer(Enum.KeyCode.X,HealthDifference)
end
end
end
end)
victimized.OnClientEvent:Connect(function(victim)
if victim.Name ~= c.Name then
return
elseif victim.Name == c.Name then
messenger:FireServer("Countered")
coroutine.resume(coroutine.create(function()
dbcs["Global"] = true
task.wait(8)
dbcs["Global"] = false
end))
end
end)
uis.InputBegan:Connect(function(input,gps)
if gps then
return
end
if input.KeyCode == Enum.KeyCode.F then
if dbcs["F"] == false and dbcs["Global"] == false then
messenger:FireServer(Enum.KeyCode.F)
coroutine.resume(coroutine.create(function()
dbcs["F"] = true
task.wait(15)
dbcs["F"] = false
coroutine.yield()
end))
coroutine.resume(coroutine.create(function()
dbcs["Global"] = true
task.wait(3)
dbcs["Global"] = false
coroutine.yield()
end))
local fanim = hum:LoadAnimation(rs.Anims.f)
fanim:Play()
local fconnection
local function fmovec(kfname)
if kfname == "StartAnim" then
print(kfname)
hum.WalkSpeed = 2
elseif kfname == "StartCharge" then
print(kfname)
hum.WalkSpeed = 0
elseif kfname == "EndCharge" then
fAttack:FireServer(Enum.KeyCode.F)
elseif kfname == "StartAttack" then
print(kfname)
elseif kfname == "EndAnim" then
hum.WalkSpeed = 16
fconnection:Disconnect()
end
end
fconnection = fanim.KeyframeReached:Connect(fmovec)
end
elseif input.KeyCode == Enum.KeyCode.X then
if dbcs["X"] == false and dbcs["Global"] == false then
messenger:FireServer(Enum.KeyCode.X)
coroutine.resume(coroutine.create(function()
dbcs["X"] = true
task.wait(25)
dbcs["X"] = false
end))
coroutine.resume(coroutine.create(function()
dbcs["Global"] = true
task.wait(6)
dbcs["Global"] = false
end))
fAttack:FireServer(Enum.KeyCode.X)
end
end
end)