Attempt to call a table value error

Hi, I’m trying to make a script though on line 40 it says it attempted to call a table value.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local DoorMessage = ReplicatedStorage.Events:WaitForChild("DoorMessage")

local TimerSpeed = ReplicatedStorage.Values:WaitForChild("TimerSpeed")
local MultiplierVisible = ReplicatedStorage.Values:WaitForChild("MultiplierVisible")
local Multiplies = ReplicatedStorage.Values:WaitForChild("Multiplies")
local Minutes = ReplicatedStorage.Values:WaitForChild("Minutes")
local Seconds = ReplicatedStorage.Values:WaitForChild("Seconds")

local Winners = {}

script.Parent.Touched:Connect(function(Hit)
	
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	
	if not Hit.Parent:FindFirstChild("Humanoid") then return end
	if table.find(Winners, Player.UserId) then return end
	
	table.insert(Winners, Player.UserId)
	
	TimerSpeed.Value = TimerSpeed.Value / 2
	DoorMessage:FireAllClients(Player)
	MultiplierVisible.Value = true
	Multiplies.Value = Multiplies.Value * 2 
	
	local PlayerCandy = Player.leaderstats:WaitForChild("🍬 Candy")
	local CandyValue = Player.DoubleCandy.Value and 160 or 80

	if not PlayerCandy then return end

	PlayerCandy.Value += CandyValue 
end)

Minutes.Changed:Connect(function()
	
	if Minutes.Value == 3 and Seconds.Value == 0 then
		
		Winners{}
	end
end)

Error:

Any help is appreciated!

Here you are calling a table value

That line is to clear the table but I don’t know how to fix the error.

You fix the error by taking out or changing that line.

If you want to make a blank table you can do

Winners = {} -- this will overwrite the variable with a new table not actually change the old one but it's fine cuz gc

Or you can do

table.clear(Winner)
1 Like

You can either use table.Clear or Winners = {}

1 Like

Oh I see I miss wrote that line, thanks for the help.

1 Like