Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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!

0
u don't do fp.Value.Changed u do fp.Changed:Connect(function() HappyTimIsHim 652 — 5y

1 answer

Log in to vote
3
Answered by
yHasteeD 1819 Moderation Voter
5 years ago

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

Ad

Answer this question