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

Line 5: attempt to index field 'Value' (a number value)? [Solved]

Asked by 9 years ago
local datastore = game:GetService("DataStoreService"):GetDataStore("countdowncreditservice")
game.Players.PlayerAdded:connect(function(player)
    while true do
        wait()
        player.statistics.credits.Value.Changed:connect(function()
            local key = "plyr-"..player.userId
            local savedvalue = {player.statistics.credits.Value}
            datastore:SetAsync(key, savedvalue)
            print(savedvalue)
        end)
    end
end)

I do not know what the issue is here. I am simply checking if a value has changed, but it returns the following error:

11:45:23.269 - ServerScriptService.creditsrealtimeupdate:5: attempt to index field 'Value' (a number value)

What is the problem here?

0
This is important. qq dirty_catheter 7 — 9y

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

I assume credits is the NumberValue? Changed is an event of credits itself, not of its Value property. Simply remove .Value from line five to fix this.

Ad

Answer this question