This may sound nooby and whatnot, but I was making a badge giver in my game that awards you a badge when the team you're on has a certain amount of Moral. I was going to make it look something like this:
while true do wait(.1) Player = game.Players:GetPlayerFromCharacter(script.Parent) Badge = game:GetService("BadgeService") if Player.Team == game.Teams.Prussians then if game.Teams.Prussians.Moral.Value >= 50 then Badge:AwardBadge(Player.UserId, 11223344) end end end
This is fine, but I have quite a few other scripts that also loop quickly to find something, and I feel like a lot of loops could slow down my game (as the title implies) I could instead use a .Changed event on the value instead, though this would mean new players wouldn't get the badge until the value changes again.
I think the answer will be very simple. use .Changed event rather than doing endless while loop.
The second issue, new users don't get the badge, it is easier to resolve, just use
game.Players.PlayerAdded:connect(function(player) --give a badge end)