I’m using attributes to check everything, so when I block I set a blocking attribute to true, And in the other script I set can_hit and can_heavy to false when the blocking, stunned, or iframes attribute is true.
(CombatManager)
local CAS = game:GetService("ContextActionService")
local Combat_Event = game.ReplicatedStorage.Combat_Event
local player = game.Players.LocalPlayer
local Character = player.Character
local humanoid = Character:WaitForChild("Humanoid")
local Heavy_Event = game.ReplicatedStorage.Heavy_Event
local can_heavy = true
local combo = 1
local last_hit = 0
local can_hit = true
local lastM1 = os.clock()
if humanoid:GetAttribute("Blocking", true) == true or humanoid:GetAttribute("Stunned", true) == true then
can_heavy = false
can_hit = false
end
BlockUser
local block_event = game.ReplicatedStorage.Block_Event
block_event.OnServerEvent:Connect(function(player)
local character = player.Character
local hum = character:WaitForChild("Humanoid")
hum:SetAttribute("Blocking", true)
print("blocking")
hum:SetAttribute("Parry", true)
task.wait(0.2)
hum:SetAttribute("Parry", false)
end)
local unblock_event = game.ReplicatedStorage.Unblock_Event
unblock_event.OnServerEvent:Connect(function(player)
local character = player.Character
local hum = character:WaitForChild("Humanoid")
hum:SetAttribute("Blocking", false)
print("stopped blocking")
end)
When calling :GetAttribute(), it’s only meant to have the name of the Attribute you’re looking for, without a second argument.
Updating that to directly check if each of the humanoid:GetAttribute("AttributeName") calls are equal to true would resolve one aspect of that.
Example
if
humanoid:GetAttribute("Blocking") == true
or humanoid:GetAttribute("Stunned") == true
then
Another problem that may be occurring is that the condition is only checked for once (when the script runs for the first time) because it is not being included in a loop or function that would be able to check again if either of those Attributes are equal to true. If you want to update the can_heavy and can_hit variables every time those Attributes are updated to true, you can use :GetAttributeChangedSignal() to detect when its value changes.
Example Revision
local function updateCanVariables(attributeName)
local attributeValue == humanoid:GetAttribute(attributeName)
if attributeValue == true
can_heavy = false
can_hit = false
end
end
humanoid:GetAttributeChangedSignal("Blocking"):Connect(function()
updateCanVariables("Blocking")
end)
humanoid:GetAttributeChangedSignal("Stunned"):Connect(function()
updateCanVariables("Stunned")
end)