So I was making a script where when the timer ends, the winner(s) will get their reward for winning but when It gets to the reward giving bit of code, it gives me an error.
The script:
local ingamePlayersFolder = game.Workspace:WaitForChild("IngamePlayers"):GetChildren()
local winnersFolder = game.Workspace:WaitForChild("Winners"):GetChildren()
if #winnersFolder >= 1 or #ingamePlayersFolder >= 1 then
stats.Value = "Players win!"
if #winnersFolder >= 1 then
for i = 1, #winnersFolder do
game.Players[#winnersFolder[1]].leaderstats.Bux.Value = game.Players[#winnersFolder[1]].leaderstats.Bux.Value + winnersReward
end
end
The error:
Workspace.GameController:79: attempt to get length of a Instance value

3 comments
which line is 79 lmao and show us the line of the instance
Line 79 was the line where game.Players[#winnersFolder[1]].leaderstats.Bux.Value = game.Players[#winnersFolder[1]].leaderstats.Bux.Value + winnersReward is which is the same line where the error occurred.
There isn't an Instance but I still get the error which directs me to that.