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 » Scripting Helpers
Home Search
 

Badge Help.

Previous Thread :: Next Thread 
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 12:38 AM
This works, all expect the 2nd if statement does not check if the user owns the shirt.
It just gives anyone that enters the badge.
I cant figure it out, anyone have any ideas?
Also, there is no output and I did try it in online mode.


game.Players.PlayerAdded:connect(function(Player)
wait(3)
local BS = game:GetService("BadgeService")
local MS = game:GetService("MarketplaceService")
if BS:UserHasBadge(Player.userId, 77255432) then
print("User has badge.")
else
BS:AwardBadge(Player.userId, 77255432)
game.Workspace.BadgeSound:Play()
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: Thanks for coming!"
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
end

if MS:PlayerOwnsAsset(Player, 6503377) then
BS:AwardBadge(Player.userId, 77295328)
game.Workspace.BadgeSound:Play()
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: VIP!"
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
end

end)
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
13 Jul 2013 12:54 AM
I don't really see any errors, but you did have a typo, it's except, not expect :P

But anyways, try making BS, and MS global variables by removing the 'local' before them. And shouldn't there be another argument in the TweenPosition() that is true or false?
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 01:06 AM
Zack, I have never used true or false when making them.

And they work fine.

The Tween is not the problem it all works fine, it just gives people without the shirt the badge also.

Also I just try'ed taking the local away and it still did not work.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
13 Jul 2013 01:12 AM
Well then I don't know .Try make a seperate function to check for it.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
13 Jul 2013 01:13 AM
I don't actually suggest removing the local variable in this case. Local variables are accessed faster by the game.

~ Linguam latinam est optimum ~
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 01:28 AM
There must be something wrong...

The shirt is suppose to be my main vip shirt for Elemental Wars.

Could someone see if maybe I am not putting the right Id, all tho i have try'ed both.

Idk if you are suppose to take 1 away from it or not when using it like this.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
13 Jul 2013 01:32 AM
The ID is correct...

~ Linguam latinam est optimum ~
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
13 Jul 2013 01:54 AM
Not sure if this will work. Also make sure all of the guis after the second if statement do not have an spelling errors.

local BS = game:GetService("BadgeService")
local MS = game:GetService("MarketplaceService")

function CheckAsset(thePlayer)
if MS:PlayerOwnsAsset(thePlayer, 6503377) then
BS:AwardBadge(thePlayer.userId, 77295328)
game.Workspace.BadgeSound:Play()
thePlayer.PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: VIP!"
thePlayer.PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
thePlayer.PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
end
end

game.Players.PlayerAdded:connect(function(Player)
wait(3)
if not BS:UserHasBadge(Player.useId, 77255432) then
BS:AwardBadge(Player.userId, 77255432)
game.Workspace.BadgeSound:Play()
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: Thanks for coming!"
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
else print("User has badge.")
end

CheckAsset(Player)

end)
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
13 Jul 2013 01:54 AM
@dek, didn't know that o:
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 03:06 AM
ZachBloxx, that does the same thing mine does.

It even gives the player without the t-shirt the badge.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
13 Jul 2013 03:11 AM
No.

"if MS:PlayerOwnsAsset(thePlayer, 6503377) then
BS:AwardBadge(thePlayer.userId, 77295328) "

It checks if the player owns the t-shirt, then it awards the badge.

And well then, I don't know how to fix this.
Report Abuse
IbossUnot is not online. IbossUnot
Joined: 28 Feb 2013
Total Posts: 2038
13 Jul 2013 03:37 AM
I fixed it, I am just going to use the UserHasBadge to check if player owns the t-shirt, sense PlayerOwnsAsset is not working.
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 03:38 AM
oops, anyways ^^
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 03:42 AM
Ok so now i have the code below.
And I get this output "Workspace.Script, line 17 Unable to cast value to Object"



game.Players.PlayerAdded:connect(function(Player)
wait(3)
local BS = game:GetService("BadgeService")
local GP = game:GetService("GamePassService")
if game:GetService("BadgeService"):UserHasBadge(Player.userId, 77255432) then
print("User has badge.")
else
BS:AwardBadge(Player.userId, 77255432)
game.Workspace.BadgeSound:Play()
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: Thanks for coming!"
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
end

if BS:UserHasBadge(Player.userId, 6503377) or GP:PlayerHasPass(Player.userId, 122345134) then
game:GetService("BadgeService"):AwardBadge(Player.userId, 77295328)
game.Workspace.BadgeSound:Play()
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge.TextLabel.Text = "You have earned a badge: VIP!"
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, 10), "Out", "Quad", 1)
wait(5)
game.Players[Player.Name].PlayerGui.GameShop.GiveBadge:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quad", 1)
wait(3)
end

end)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Jul 2013 04:18 AM
Please post the line mentioned in the Output next time. PlayerHasPass (and PlayerOwnsAsset fyi) use the Player object, rather than the Player's userId, like UserHasBadge. I'm not sure why.

if BS:UserHasBadge(Player.userId, 6503377) or GP:PlayerHasPass(Player, 122345134) then
Report Abuse
kinglime is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
13 Jul 2013 10:06 AM
You cant see.
I did post the line in the output, maybe you should read my post above yours.
That was it, all that was in the output but I fixed it last night right after I posted that.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
13 Jul 2013 10:44 AM
I meant post the actual line of code.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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