How to GET attribute?

Hello, I have this remote event and it passes an object when its clicked via a click detector. everything works good except for the fact that for some reason attributes arent passing through my remove event.

as you can see in my script:

-- // server
script.Parent:SetAttribute("Cash", 10)
game.ReplicatedStorage.RemoteEvent:FireClient(plr, script.parent)

-- // client
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(object)
	print(object:GetAttribute("Cash")) -- // prints nil
end)

here is an example that I’m trying to do but for some reason I am unable to get the attribute from the param passed object.

what is the error provided? is it null/nill? is the object accessible on the client?

1 Like

use Values instead of attributes. (intValues, NumberValues, BoolValues)

Where is the object located when it’s passed over?

I realized the issue was because I was passing the part that was being clicked and not the actual model (the model was the one with the attributes.) I do have to say I strongly disagree with your point.

Why you shouldnt use value objects

  1. Attributes are faster
  2. Attributes are cleaner
  3. Attributes are better for managing. Ex: setattribute() only creates a new attribute if a old attribute doesnt exist with the same name.
1 Like

You did script.parent, not script.Parent

1 Like

Yeah, Attributes are superior to independent values. Once I learned about attributes I never looked back, as there isn’t really any reason to use independent values that couldn’t already be done in a simpler and more organized method with code or attributes.

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