generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Help, badges, this should reward the player a badge

Previous Thread :: Next Thread 
thegoodpuppy is not online. thegoodpuppy
Joined: 07 Jul 2011
Total Posts: 2737
10 Jan 2017 05:40 PM
local BID = 607126916 --
local BS = game:GetService("BadgeService")

game.Players.PlayerAdded:connect(function(plr)
plr = game.Players:FindFirstChild(plr.Name)
plr.leaderstats.Wins.Changed:connect(function()
if plr.leaderstats.Wins >= 50 then
BS:AwardBadge(plr.userId, BID)
end
end)
end)

They have a leaderstats with wins, and when it gets over 50 or to 50, I want it so they get the badge. I've tested it online, and there isn't a popup in the game that it has that tells me "you got this badge" or whatever. I tested it yesterday, and in the badges stats it says "gotten yesterday: 0". Anyone know whats wrong with this? Or will it work with other players
Report Abuse
killerbot29003 is not online. killerbot29003
Joined: 04 Oct 2014
Total Posts: 3054
10 Jan 2017 05:48 PM
why are you doing
plr = game.Players:FindFirstChild(plr.Name)

the event already gives u the player object
you also have to keep in mind that leaderstats could potentially not be there before the .Changed event is used on it, so you should wait for leaderstats and the "Wins".


This siggy is copyrighted ©
Report Abuse
thegoodpuppy is not online. thegoodpuppy
Joined: 07 Jul 2011
Total Posts: 2737
10 Jan 2017 05:50 PM
So this?

local BID = 607126916
local BS = game:GetService("BadgeService")

game.Players.PlayerAdded:connect(function(plr)
ldrstats = plr:WaitForChild("leaderstats")
wins = ldrstats:WaitForChild("Wins")
wins.Changed:connect(function()
if plr.leaderstats.Wins >= 50 then
BS:AwardBadge(plr.userId, BID)
end
end)
end)
Report Abuse
killerbot29003 is not online. killerbot29003
Joined: 04 Oct 2014
Total Posts: 3054
10 Jan 2017 05:51 PM
ya

use .UserId instead of .userId


This siggy is copyrighted ©
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image