How To Get a Attribute's Value

I am very new to Attributes and this it the first time I am using them.

Help: I am trying to get the Altribute’s Value but I don’t know how.

Problem: Right know the text is just showing Clock

--==============================================================================
--LOCAL SCRIPT >> SCRIPTS
--==============================================================================
--<<VERIABELS>>
local DataValues = workspace.DataValues
local Clock = DataValues:GetAttribute("Clock")
local Info = DataValues:GetAttribute("Info")
local AnouncmentLabel = script.Parent.Parent.ScoreFrame:WaitForChild("AnouncmentLabel")
local ClockLabel = script.Parent.Parent.ScoreFrame:WaitForChild("ClockLabel")
--==============================================================================
--<<FUNCTIONS>>
DataValues.AttributeChanged:Connect(function(Clock)
	ClockLabel.Text = Clock
end)

DataValues.AttributeChanged:Connect(function(Info)
	AnouncmentLabel.Text = Info
end)
--==============================================================================
1 Like

AttributeChanged passes attribute name. You can use it in GetAttribute().

-- Don't forget to set the initial value in case the attribute values are
-- changed before the listener is connected
ClockLabel.Text = DataValues:GetAttribute(attribute)
AnouncmentLabel.Text = DataValues:GetAttribute(attribute)

DataValues.AttributeChanged:Connect(function(attribute)
	if attribute == "Clock" then
		ClockLabel.Text = DataValues:GetAttribute(attribute)
	elseif attribute == "Info" then
		AnouncmentLabel.Text = DataValues:GetAttribute(attribute)
	end
end)

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