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

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

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?

1 comment

0

This is important. qq

1 answer

✓ Accepted answer

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.

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