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

ServerScriptService.leaderstats:23: attempt to call a table value. Wheres the error?

Asked by 4 years ago

When I was making my saved leaderboard stats, I got this error. Does anyone know how to fix it? The error is supposedly in line 23 by the way.

Script:

01local datastore = game:GetService("DataStoreService"):GetDataStore("Savedata")
02 
03game.Players.PlayerAdded:Connect(function(player)
04 
05 
06    local stats = Instance.new("Folder", player)
07    stats.Name = "leaderstats"
08 
09    local wins = Instance.new("IntValue")
10    wins.Name = "Wins"
11    wins.Parent = stats
12 
13    local coins = Instance.new("IntValue")
14    coins.Name = "Coins"
15    coins.Parent = stats
View all 33 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

Howdy!

To index a table, you use brackets - not parenthesis. Replace lines 23 and 24 with what I got below and it should work.

1wins.Value = SavedValues[1]
2coins.Value = SavedValues[2]

If this helped you out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I (or someone else) will help you out.

Be sure to check out the Roblox API Documentation as well for additional reference.

Ad

Answer this question