ValueTest = game.workspace.Partscan.Sugar.Value SugarLabel = game.workspace.Partno.SurfaceGui.Frame.Sugar game.workspace.Partscan.Sugar.Value.Changed(function(Scanthiscrap) if ValueTest == 0 then SugarLabel.Text = "Sugar 0/1" elseif ValueTest == 1 then SugarLabel.Text = "Sugar 1/1" end end)
Error:20:06:02.864 - Workspace.Partno.Script:6: attempt to index field 'Value' (a number value)
I'm not sure what this error means.. Help please?
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.
-- Have reasonable variable names, and please use WaitForChild as well. 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.