:I'm making a script that detects when an Intvalue changes by using the "Changed" event, but whatever I try gives me an error. Here is the error code along with the script I'm using:
Script:
local stats = game.Players.LocalPlayer:WaitForChild('Statistics')
debounce = true
stats.Amount.Changed:connect(function(NewValue)
if debounce == true then
debounce = false
script.Parent.Text = (NewValue..' '..stats.Name.Value)
wait(0.1)
debounce = true
end
end)
Error Code: Players.EnderGamer358.PlayerGui.MainGui.BaseFrame.Amount.ChangeText:7: attempt to concatenate field 'Value' (a nil value) 18:42:20.225 - Stack Begin 18:42:20.228 - Script 'Players.EnderGamer358.PlayerGui.MainGui.BaseFrame.Amount.ChangeText', Line 7 18:42:20.229 - Stack End
:I'm running it through a local script, could this be the problem? Or am I using the event wrong?

1 comment
stats.Name will return a string, since it is getting stats Name. If there is another ValueType within the stats folder that is named "Name", use stats["Name"] instead. Instead of getting the child "Name", it's getting the folder's actual Name property.