Attempt to call a table value

Hello, I’m working on a game with a minigame and round system and I stumbled upon this error: “attempt to call a table value” and I can’t seem to find any fix for it.

A part of my code (The error is in the for):

local playersInMinigame = game.Players:GetPlayers()

for i, v in playersInMinigame do
    v:WaitForChild("PlayerGui").Minigames:FindFirstChildWhichIsA("Frame"):Destroy()
end

Any help would be appreciated!

Try this:

local playersInMinigame = game.Players:GetPlayers()

for i, v in pairs(playersInMinigame) do
    v:WaitForChild("PlayerGui").Minigames:FindFirstChildWhichIsA("Frame"):Destroy()
end
3 Likes

I believe you have an error in your syntax, try adding brackets around playersInMiniGame found in the loop constructor function in pairs.

local Players = game:GetService("Players")
local playersInMinigame = Players:GetPlayers()

for i, v in pairs(playersInMinigame) do
	-- execute your code
end
2 Likes

Ohhhhh I forgot to type that, my bad :confused: