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

Error: Table becomes nil by just becoming nil?

Asked by 4 years ago
Edited 4 years ago

So I'm making a voting system for my game, and i have a WinningMinigame table, that the 1st and 2nd members are the minigame and its votes. When i print, at the end of the script, the winning minigame name and votes, in some situations it prints correctly, and sometimes it says:

 Workspace.Lobby.Votos.Voto:155: invalid argument #2 (string expected, got nil) - Server - Voto:155

I don't know why it does that becuase 1 line before it says the table members correctly:

Most voted minigame: Death corners with 1 votes. - Server - Voto:154

1 line after:

nil - Server - Voto:153   09:09:58.078 Most voted minigame: nil with nil votes. - Server - Voto:154

I dont know what's the problem, but it fires the same code twice and that glitches the code.

If u want to help me analyzing the script, it's here:

001local AvMinigames = game.ServerStorage.Minigames.Images:GetChildren()
002local display = script.Parent.Tela.SurfaceGui.Tela
003local votesBEV = game.ReplicatedStorage.voting
004local buttons = {script.Parent["1"], script.Parent["2"], script.Parent["3"]}
005local PlayerLocks = {}
006local VotesWithMinigames = {}
007local PlayerVotes = {}
008local ButTouchedEVS = {}
009local displays = {}
010 
011 
012for i, v in pairs(display:GetChildren()) do
013    if v.ClassName == "ImageLabel" then
014        displays[#displays + 1] = v
015    end
View all 220 lines...
1
I think you should update the vote counter before printing the table. For the reason why sometimes it runs, it is because you voted before the for loop runs. Xapelize 2658 — 4y
0
ok i fixed it np bruno13bruno13 78 — 4y

1 answer

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

You did not label any variable as "displays", but putting it after pairs in line 152. It would have give you an warning, I think you meant "display" not "displays"?

0
Note: Unlabeled variables value is defaulted as nil. Xapelize 2658 — 4y
0
Another note: You can still run the script with warnings, but not errors. Xapelize 2658 — 4y
0
This is just a guess, it is probably incorrect. You can provide more information and guesses if you want to try to solve the answer. Xapelize 2658 — 4y
0
Ok so im gonna post the script, and yes i have put the variable displays. bruno13bruno13 78 — 4y
Ad

Answer this question