Help with :GetAttributeChangedSignal() not firing

Hello so I have been learning coding on studio for 4 months now and have learned a lot, So I am trying to make a combat system that isn’t collision based (Such as Minecraft for example) to do this I need to Cast a Ray in the direction my mouse is at, But to achieve this I needed a local script to get the player’s Mouse position, So when an attribute on the tool gets changed wich is “RayCasAttack” The local script is supposed to see this and then fire a remote to cast a ray where it hits.

The issue here is that the :GetAttributeChangedSignal() Just wont care if the attribute gets changed, I also tried .AttributeChanged and got same result

Ok so here is an image of the value getting changed

Now the local script should notice this and run the function wich prints the attributes name

But It just never gets printed


(Yes you can also see local scripts here because I have testing on “Current Client”

I have tried using the .AttributeChanged event and still did not worked, I have also checked if its even reading the attribute and yes its finding it I have used a lot of methods to determing if its even getting the attribute and to check if its something else maybe.

I have never used the forum so I am making this topic because it’s my last option at getting help.

Ask me aany questions if im lacking info that should be provided

this goes in #help-and-feedback:scripting-support

how did it even get in art design support?!

Sorry very sorry, Ill change it, My mistake I have just never used the forum and I accidentally set it here, Il change it

1 Like

It appears your problem is because you are setting

RayCasAttack = true

booleans pass by value not reference so it’s not changing the actual attribute

What you need to do to set an attribute is

Instance:SetAttribute(attr_name,value)

So you are telling me this whole time, I have never been changing the attribute and Lua just thinks i made a new variable instead of changing the value of my attribute via a variable?

yes that’s what I am telling you

1 Like

So in this case should I just not use an attribute and just a value inside the tool?
And also if I ever need to, How do I change the value of an attribute

You can use Attributes there is nothing wrong with them. You just have to use.

  • Instance:GetAttribute(attr_name), to read an attribute
  • Instance:SetAttribute(attr_name,value), to set an attribute
1 Like

So i just do

FireAxeTool:SetAttribute(“RayCastAttack”, true)

1 Like

yes that’s what you do

1 Like

Alr thank you very much Sir for your help, I had actually read a lot of resources to check if I was doing anything wrong and never thought I just didnt knew how to change attributes, I will try it now and if it works ill set your reply as solution :sunglasses:

1 Like