Attribute Value Doesn't Change

I’m trying the change the value of an attribute that only stores number values but it doesn’t change no matter what way I do it. I looked for solutions that worked for other people but they don’t work for me, how do I fix this?

1 Like

Please list the code that you’re using and I’ll be able to assist you further.

First though, make sure you’re using :SetAttribute().

Example
local part = game.Workspace.Part
part:SetAttribute("CashValue", 5)
part:SetAttribute("Color", BrickColor.new("Really red"))
part:SetAttribute("PartName", "John")

part.Name = part:GetAttribute("PartName")
part.BrickColor = part:GetAttribute("Color")
print("This part is worth :$".. part:GetAttribute("CashValue"))

Documentation

Here:

Update = RunService.RenderStepped:Connect(function()
			OTS:MouseLock(true)
			NewSpring:Update()
			workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.fromOrientation(math.rad(NewSpring.Position),0,0)

			if Firing then
				if os.clock() - LastFire >= FireRate then
					if Automatic then
						if Aiming then
							
							Weapon:SetAttribute("OverheatDegrees", OverheatDegrees + 1)
							Thermostat.Temperature:TweenSize(UDim2.new(Thermostat.Temperature.Size.X.Scale,0,-(OverheatDegrees/OverheatPoint),0), "Out", "Sine", 0.2)
							
							for _, v in pairs(Crosshair:GetChildren()) do
								
								
								local Goals = {}
								local Info = TweenInfo.new(.25, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, true)

								if v.Name == "Left" then
									Goals.Position = v.Position + UDim2.new(-0.1,0,0,0)
								elseif v.Name == "Right" then
									Goals.Position = v.Position + UDim2.new(0.1,0,0,0)
								elseif v.Name == "Top" then
									Goals.Position = v.Position + UDim2.new(0,0,-0.1,0)
								elseif v.Name == "Bottom" then
									Goals.Position = v.Position + UDim2.new(0,0,0.1,0)
								end

								TweenService:Create(v, Info, Goals):Play()

							end
							
							NewSpring:Impulse(Recoil)
							FireAnim:Play()
							FireSound:Play()
							local MousePosition = Mouse.Hit.Position
							FireRE:FireServer(MousePosition, Weapon)
							LastFire = os.clock()
						end
					end
				end

(OverheatDegrees is set to Weapon:GetAttribute(“OverheatDegrees”))

Should OverheatDegrees be redefined to reflect its updated :SetAttribute() value?

If Weapon:GetAttribute("OverheatDegrees) is being referenced above the .RenderStepped event, I’m pretty sure it’s holding onto it’s old value, not the current value it receives after having +1 added to it from :SetAttribute().

Weapon:SetAttribute("OverheatDegrees", OverheatDegrees + 1)
OverheatDegrees = Weapon:GetAttribute("OverheatDegrees")							
Thermostat.Temperature:TweenSize(UDim2.new(Thermostat.Temperature.Size.X.Scale,0,-(OverheatDegrees/OverheatPoint),0), "Out", "Sine", 0.2)

I might be wrong, also. The Attribute isn’t being changed on client and server?
Perhaps sending over the Attribute’s new value to the server might resolve this.
Not sure!

I’ll try your solution, thanks for trying to help!

1 Like