Hello. I have a question related to a very finicky stance + block system I am doing. I am currently trying to make the release system, but the issue comes in when I attempt to do it with the stances. (Stances are just different modes of combat.) When I attempt to do an attribute change event to check if the character has changed their stance, the issue comes in that the blocking stance stays indefinite, but it’s looped. I unloop it though once I decide to do the released even, but it seems to just not work. I don’t really know I could execute the script properly.
function StanceSwitch.BlockSwitches(Player, Count)
if Count == 1 then
Player:SetAttribute("BStance", BlockStances[1])
local Anim, Length = AnimationModule.getSingleAnimation(Player.Character.Humanoid, script.Animations.BlockStances.BaseStance)
Anim.Looped = true
Anim:Play()
Player:GetAttributeChangedSignal("BStance"):Connect(function()
if Count ~= 1 or Player:GetAttribute("BStance") ~= BlockStances[1] then
Anim.Looped = false
Anim:Stop()
end
end)
elseif Count == 2 then
Player:SetAttribute("BStance", BlockStances[2])
local Anim, Length = AnimationModule.getSingleAnimation(Player.Character.Humanoid, script.Animations.BlockStances.UpperStance)
Anim.Looped = true
Anim:Play()
Player:GetAttributeChangedSignal("BStance"):Connect(function()
if Count ~= 2 or Player:GetAttribute("BStance") ~= BlockStances[2] then
Anim.Looped = false
Anim:Stop()
end
end)
elseif Count == 3 then
Player:SetAttribute("BStance", BlockStances[3])
local Anim, Length = AnimationModule.getSingleAnimation(Player.Character.Humanoid, script.Animations.BlockStances.LowerStance)
Anim.Looped = true
Anim:Play()
Player:GetAttributeChangedSignal("BStance"):Connect(function()
if Count ~= 3 or Player:GetAttribute("BStance") ~= BlockStances[3] then
Anim.Looped = false
Anim:Stop()
end
end)
end
end
The blocking script is much more simpler.
local blocking script
UserInputService.InputBegan:Connect(function(Input, GPE)
if GPE == true then return end
if Character:WaitForChild("StatusFolder"):FindFirstChild("Stunned") then
print('loser')
return
end
if Character:FindFirstChildOfClass("Tool") then
print('toolienotallowed')
return
end
if Input.KeyCode == Enum.KeyCode.F then
if Debounce == false then
Debounce = true
ButtonDown = true
ReplicatedStorage.RemoteEvents.CombatEvents.Blocking:FireServer(Count)
end
end
end)
UserInputService.InputEnded:Connect(function(Input, GPE)
if GPE == true then return end
if Character:WaitForChild("StatusFolder"):FindFirstChild("Stunned") then
print('loser')
return
end
if Character:FindFirstChildOfClass("Tool") then
print('toolienotallowed')
return
end
if Input.KeyCode == Enum.KeyCode.F and ButtonDown == true then
ReplicatedStorage.RemoteEvents.CombatEvents.Rele
blockin server script
Blocking.OnServerEvent:Connect(function(Player, Count)
local Character = Player.Character
if Debounce == false then
if Character:GetAttribute("CanAttack", true) or Character:GetAttribute("Running", true) then return end
Character:SetAttribute("IsBlocking", true)
end
end)
Release.OnServerEvent:Connect(function(Player)
local Character = Player.Character
Character:SetAttribute("IsBlocking", false)
task.wait(3)
Debounce = false
end)