Attempt to index nil with value

What’s the problem with my code?

The problem is that I want to save “Value”, “MinValue” and “MaxValue” (DoubleConstrainedValue)

The part of the code that is the problem

if success and GetStats ~= nil then
rsd.Value = GetStats[1]
rsd.MaxValue = GetStats[1]
rsd.MinValue = GetStats[1]
points.Value = GetStats[2]
points.MaxValue = GetStats[2]
points.MinValue = GetStats[2]
print("StatsData loaded for "..PlayerAdded.Name)
else
rsd.Value = 0
rsd.MaxValue = 100
rsd.MinValue = 0
points.Value = 0
points.MaxValue = 10
points.MinValue = 0
print("New StatsData for "..PlayerAdded.Name)
end	

When I try to save only “Value” then everything works properly.

Code that works properly:

if success and GetStats ~= nil then
rsd.Value = GetStats[1]
points.Value = GetStats[2]
print("StatsData loaded for "..PlayerAdded.Name)
else
rsd.Value = 0
points.Value = 0
print("New StatsData for "..PlayerAdded.Name)
end	

where does it error, on the rsd.Value = GetStats[1] or rsd.MaxValue = GetStats[1]?

The error appears on rsd.MaxValue, sometimes an error doesn’t come up but it doesn’t save anything.

ok maybe you need to add a .Value behind that .MaxValue?
like:

rsd.MaxValue.Value = GetStats[1]
rsd.MinValue.Value = GetStats[1]

Ok i figured out the meaning of the numbers, i fixed the code.