Attribute of LocalScript is being ignored

I added an attribute named “CanM1Air” to a LocalScript, which says if the M1 Air attack can be used. The attribute is mentioned in the script 2 times, the second time is in --[] for testing purposes. I put disabled breakpoints where the attribute is mentioned.

  1. Does the attack if the attribute is true

    If the image is too small:
M1Input.Pressed:Connect(function()
	if char:GetAttribute("Attacked") == false then

		-- Air M1
		print(script:GetAttribute('CanM1Air'))
		if char:GetAttribute("Attacking") == 0 and script:GetAttribute('CanM1Air') == true and hum:GetState() == Enum.HumanoidStateType.Jumping or hum:GetState() == Enum.HumanoidStateType.Freefall then
			script:SetAttribute('CanM1Air', false)
			lawHitboxRemote:FireServer(5)
			lawVFXRemote:FireServer(5, "on")
			plr.Character:SetAttribute("Attacking", 1)
			AirAT:Play()

			for i,v in pairs(char.M1AirVFX:GetDescendants()) do
				if v:IsA("ParticleEmitter") or v:IsA("Beam") then
					v.Enabled = true
				end
			end

			local liv = Instance.new("LinearVelocity")
			liv.MaxForce = 30000
			liv.VectorVelocity = hrp.CFrame.lookVector * 50
			liv.Attachment0 = hrp:FindFirstChild("Attachment")
			liv.Parent = hrp
			hum.AutoRotate = false

			AirAT.Stopped:Wait()
			lawHitboxRemote:FireServer("off")
			lawVFXRemote:FireServer(5, "off")
			if char:GetAttribute('Attacking') == 1 then char:SetAttribute('Attacking', 0) end
			print("air m1 stopped")
			liv:Destroy()
			hum.AutoRotate = true

			for i,v in pairs(char.M1AirVFX:GetDescendants()) do
				if v:IsA("ParticleEmitter") or v:IsA("Beam") then
					v.Enabled = false
				end
			end
			print(script:GetAttribute('CanM1Air'))
  1. Sets the attribute to true, it shouldn’t matter because its a comment

I just added this, theres no duplicate scripts, no attribute with the same name, or the attribute being mentioned somewhere else. The combat input system works, theres other attacks that are a lot more complex in the if M1Input.Pressed:Connect() block of code.

This is the test result:

In both the output and the propterties tab, it shows CanM1Air stays false.
Screenshot 2025-10-24 140817

Why is the attribute being ignored?

1 Like

I deleted the attribute & the related code in Part 1 except for the part that checks the attribute. Its the same thing, if script:GetAttribute(‘CanM1Air’) == true is being ignored despite the attribute not existing.

The other attributes such as if char:GetAttribute(“Attacking”) == 0 / the UltCooldown attribute of the LocalScript are being respected.

I think the problem is in condition:

local a : boolean = true
local attribute_is_true : boolean = false
local c : boolean = true
local d : boolean = true

if a and attribute_is_true and c or d then
	print("true")
else
	print("false")
end

because of or d.
The values of first three booleans do not matter if d is true.
Sorry if I missed something.

2 Likes

Yup, the conditional statement is the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.