I got this error that breaks the whole game, how could I fix the problem?
It’s hard to try to fix the problem because it works like 99% of the time, so I would appreciate all kind of help.
This is where it breaks, if you want more code just ask
if v:IsInGroup(9340560) == true then
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + 5
end
function module.Winners(reward,bitname,winname)
runningFunction.Value = "Winners"
local playersnowin = 0
for i,v in pairs(game.Players:GetChildren()) do
if workspace:FindFirstChild("Minigame") and v:FindFirstChild("RankSystem") and v.RankSystem:FindFirstChild("Current") and v:FindFirstChild("leaderstats") and v.leaderstats:FindFirstChild(bitname) and v.leaderstats:FindFirstChild(winname) and v:FindFirstChild("Playing") and v.Playing.Value == true then
local vip = v.Passes:FindFirstChild("PlayerHasVIP")
local passExp = v.Passes:FindFirstChild("PlayerHasXTwoExp")
local passBits = v.Passes:FindFirstChild("PlayerHasXTwoBits")
if gamefolder.Players.Value <= workspace.Minigame.GameConfig.PlayersToEnd.Value then
status.Value = ""
if v:IsInGroup(9340560) == true then
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + 5
end
if passExp.Value == true and vip.Value == false then
v.RankSystem.Current.Value = v.RankSystem.Current.Value + 20
end
if passBits.Value == true and vip.Value == false then
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + 20
end
if vip.Value == true then
if vip.Value == true and passBits.Value == true then
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + 60 -- Pass BIT
elseif vip.Value == true and passBits.Value == false then
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + 20
end
if vip.Value == true and passExp.Value == true then
v.RankSystem.Current.Value = v.RankSystem.Current.Value + 40 -- Pass EXP
elseif vip.Value == true and passExp.Value == false then
v.RankSystem.Current.Value = v.RankSystem.Current.Value + 10
end
end
v.leaderstats[bitname].Value = v.leaderstats[bitname].Value + reward
v.leaderstats[winname].Value = v.leaderstats[winname].Value + 1 --Normal reward
v.RankSystem.Current.Value = v.RankSystem.Current.Value + 20
game.ReplicatedStorage.Remotes.PlayerWins:FireAllClients(v)
else
status.Value = "No Winner!"
end
else
playersnowin = playersnowin + 1
end
if playersnowin == i then
status.Value = "No Winner!"
end
end
end
GetChildren() returns every object parented inside the player, not the individual Player Instances; if you want to check that a Player is in a specific group, use GetPlayers() method like @ItsNickBoi110 mentioned
It’s alright, but I would also like to mention GetPlayers() only returns Player instances, so technically there would be no use in using if v:IsA('Player') then.
This error does not happen all the time so I don’t know, but I did what @AsynchronousMatrix and also did what you suggested. So I think it will work, thanks.