I have this money giving system and it bases how much money they receive on what team they are on. I keep getting the error that callbacks cannot yield. I'm quite confused as I don't get this error if I remove those "ifs" regarding whether they're on a specific team or not.
local DS = game:GetService("DataStoreService"):GetDataStore("CoB_Money3")
x = 50
game.Players.PlayerAdded:connect(function(plr)
while x <= 50 and x > 0 do
wait(1)
x = x - 1
plr.PlayerGui.Menu_UI.Main.Wait.Text = x.."s"
if x == 0 then
x = 50
DS:UpdateAsync("user_"..plr.userId, function(o)
local n = o or 0
if plr.TeamColor == BrickColor.new("Smoky grey") and not plr:IsInGroup(2634853) then -- If they're not in Broadview
return n + 10
elseif plr.TeamColor == BrickColor.new("Smoky grey") and plr:IsInGroup(2634853) then -- If they're a citizen of Broadview
return n + 15
elseif plr.TeamColor == BrickColor.new("Deep blue") then -- If they're on the BPD team
return n + 20
elseif plr.TeamColor == BrickColor.new("Persimmon") then -- If they're on the BFD team
return n + 20
end
end)
end
end
end)

1 comment
I really appreciate the answer-I did not realize that IsInGroup was the function yielding this. Thanks!