Hello I am new to coding and this one strip of code has gotten me stumped.
Here it is.
if #plrs == 1 then --They won wow Status.Value = "The conquerer is.."..plrs(1).Name --The error is this row plrs(1).leaderstats.Bucks.Value = plrs(1).leaderstats.Bucks.Value + reward break
plrs is a local table of how many players are left in the game and here i am trying to get their name to show up when they are the last player left alive. Though when there is one player left it just continues showing the status text that shows when the game is playing which is.
"There are # seconds remaining and # players remaining!"
When the players remaining goes down to 1 the status stops updating and says
"There are # seconds remaining and 1 players remaining!"
The seconds stop going down and nothing happens. What i want to happen is the status text to be updated to.
"The conquerer is.. (last person alive's name)!"
Thanks for help in advance.
attempt to call local 'plrs' (a table value) error?
The problem is in the error. You're trying to call plrs
via ()
but plrs
is a table {}
; what you're doing --> plrs(...)
I assume you're trying to index the first player in the plrs
array. When indexing an array using a number position you use brackets []
.
Like this: plrs[1]
local myTable = { "hehe", "epic" } local firstIndex = myTable[1] --// retreives the first index which is "hehe"
When indexing an array, you should use square brackets instead of round bracket. So do players[1]
, not players(1)