The Enemy is supposed to have their CurrentAction change from "AttackLeft" to "Flinch" when hit, but it only seems to read as "Flinch" on one script while the other script still reads it as "AttackLeft".
Video: https://streamable.com/j4f2l2
Script 1 (server script):
local UserInputService = game:GetService("UserInputService")
local character = script.Parent.Parent
local debounce = script.Parent.Debounce.Value
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local swordDamage = script.Parent.WeaponDamageBindableEvent
local beingUsed = script.Parent.BeingUsedBindableEvent
local CurrentAction = script.Parent.Parent.CurrentAction.Value
--[[local AudioPlayerModule = require(ReplicatedStorage:WaitForChild("AudioPlayer")
AudioPlayerModule.preloadaudio({
})]]
--[[
11768323667 right
11768327293 up
11768331665 left
]]
repeat wait() until character.Humanoid
local humanoid = character.Humanoid
local anim = Instance.new("Animation")
anim.Parent = humanoid
anim.AnimationId = "https://www.roblox.com/asset/?id=11779584892"
local playAnim = humanoid:LoadAnimation(anim)
while true do
wait()
print(CurrentAction)
if CurrentAction == "AttackLeft" and not playAnim.IsPlaying then
CurrentAction = nil
end
if debounce ~= true and CurrentAction ~= "Flinch" and not playAnim.IsPlaying then
debounce = true
playAnim:Play(0, 1, 1)
CurrentAction = "AttackLeft"
local swordDamageCoroutine = coroutine.create(function()
swordDamage:Fire(3, true, 0.7, 0.2, "AttackLeft")
end)
coroutine.resume(swordDamageCoroutine)
--sound goes here
--AudioPlayerModule.playAudio("")
local proceed = false
flinchCalculator = RunService.Heartbeat:Connect(function(deltaTime)
if playAnim.IsPlaying == false then proceed = true end
if CurrentAction ~= "AttackLeft" then proceed = true end
if proceed == true then
if CurrentAction ~= "Flinch" then CurrentAction = nil end
playAnim:Stop()
swordDamage:Fire(0, false, false, false)
beingUsed:Fire()
debounce = false
flinchCalculator:Disconnect()
wait(0.5)
end
end)
end
end
Script 2 (server script):
local UserInputService = game:GetService("UserInputService")
local character = script.Parent.Parent
local debounce = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local swordDamage = ReplicatedStorage.SwordDamageRemoteFunction
local beingUsed = ReplicatedStorage.BeingUsedRemoteFunction
local tookDamage = script.Parent.TookDamageBindableEvent
local CurrentAction = script.Parent.Parent.CurrentAction.Value
repeat wait() until character.Humanoid
local humanoid = character.Humanoid
local anim = Instance.new("Animation")
anim.Parent = humanoid
anim.AnimationId = "https://www.roblox.com/asset/?id=11779381761"
local playAnim = humanoid:LoadAnimation(anim)
tookDamage.Event:Connect(function(flinch, flinchTime)
if flinch then
playAnim:Play(0, 1, 1)
CurrentAction = "Flinch"
print(CurrentAction)
wait(flinchTime)
CurrentAction = nil
end
end)
