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?
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.