✓ Accepted answer
Future reference
Analyze your error messages. Even if it looks like something you deem confusing, the output will tell you first-hand what's not working in your program in the simplest way possible.
Error
Just like your error message states, you're trying to index a number value for Changed - which is a complete logic error. You probably meant to use the Changed event on the actual object, and not it's value.
It also seems that you tried indexing game for workspace. This is another problem, since Lua is case-sensitive and will not recognize workspace as an actual variable. You'd either replace it with game.Workspace, or just the built-in variable workspace, which is the one you should be using.
local sugar = workspace:WaitForChild("Partscan"):WaitForChild("Sugar")
local SugarLabel = workspace:WaitForChild("Partno"):WaitForChild("SurfaceGui"):WaitForChild("Frame").Sugar
sugar.Changed:connect(function(prop)
if sugar.Value == 0 then
SugarLabel.Text = "Sugar 0/1"
elseif sugar.Value == 1 then
SugarLabel.Text = "Sugar 1/1"
end
end)
If you have any questions, let me know.
2 comments
Actually, I'm using a Numbervalue, not a object...
A NumberValue is an object.