Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does "attempt to index field 'Value' (a number value) mean?"

I get a error when I try to change a speed of something when a value is changed. The error stats "attempt to index field 'Value' (a number value)".

When I execute this code I get that error:

fp.Value.Changed:connect(function()
	for i = 0, 360, 1 do
		p.Orientation = Vector3.new(0, i, -90)
		wait(fp.Value)
	end
end)

fp is the NumberValue in ReplicatedStorage.

Before you suggest that I have not attached a value to fp, I have.

Please clarify what that error means and how to avoid it in the future. Thanks :D!

1 comment

0

u don't do fp.Value.Changed u do fp.Changed:Connect(function()

1 answer

✓ Accepted answer

You need to use instance.Changed not instance.Value.Changed, if you use instance.Value.Changed will return this error, for fix this only remove .Value in line 1

Example:

local instance = workspace.MyValue
instance.Changed:Connect(function()
	print("MyValue changed")
end)

Also :connect is deprecated, use :Connect

Fixed script:

fp.Changed:Connect(function()
    for i = 0, 360, 1 do
        p.Orientation = Vector3.new(0, i, -90)
        wait(fp.Value)
    end
end)

Wiki pages

Changed

This discussion is preserved as it was. New answers, comments, and votes are closed.