This is driving me nuts.
For some reason, this script keeps throwing an error saying that the "Changed" event on these values (more specifically as said in the output, the one at line 13) is a "nil value", even though it's right here on the Roblox Wiki:
local stats = script.Parent.Stats; local head = script.Parent.Head local gender = stats.Gender; local name = stats.Name; local desc = stats.Description gender.Changed:Connect(function() if gender.Value == 1 then head.NameGui.TextLabel.Text = name.Value.."?" elseif gender.Value == 0 then head.NameGui.TextLabel.Text = name.Value.."?" end end) name.Changed:Connect(function() if gender.Value == 1 then head.NameGui.TextLabel.Text = name.Value.."?" elseif gender.Value == 0 then head.NameGui.TextLabel.Text = name.Value.."?" end end) desc.Changed:Connect(function() head.DescriptionGui.TextLabel.Text = desc.Value end)
With my experience with the "Changed" event (on value instances, FYI), I've never received this error. Why is this happening, and how can I fix it?
The problem is that name
is not what you think it is. Instead of getting a reference to what I assume is a StringValue
called "Name" inside stats
, you are accessing the property stats.Name
. When defining name
you should do this instead:
local name = stats:FindFirstChild("Name")