|
I know you can check to see if a player owns a particular item. I thought I had the right bit of code, but it's not working. So can anyone give my the method you are supposed to use?:3 |
|
|
game:GetService("BadgeService"):UserHasBadge(userId, assetId)
I think, I've never used BadgeService before, but I hear that you can check if a player owns anything with it. |
|
KurokiJoin Date: 2009-12-27 Post Count: 18058 |
I only know the particular code to check it:
if game:GetService("BadgeService").UserHasBadge(player.Id, ID OF THE BADGE) then
--do stuff |
|
KurokiJoin Date: 2009-12-27 Post Count: 18058 |
Huzzah! I only forggot to use colons instead of a period dot! |
|
Ulla42Join Date: 2009-12-14 Post Count: 1774 |
Hm, I never thought the badge checker would check any form of ownership. Thanks, I might try experimenting with that. |
|
|
That's exactly it, thanks!:D The line I has had :UseHasAsset, not Badge. Works now, thanks a ton;D |
|
|
@kuroki
There is a property of player that contains the Id?:o That would be helpful; I was trying to use string manipulation to get it off the CharacterAppearance:P
@ulla
Yup! Got the idea from gamer101. You don't have to wear his VIP shirt into a game, so I searched the SH for an explanation. Very nifty little bit of code!:D |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
@fisherman
If you look at Player in the object browser, you will see a userId property. ^_^ |
|
|
|
I ran into a problem. It works, but it works too well. It does the stuff I want it to whether the player owns the item or not:c Here is the script:
for i, v in pairs(children) do
if v:findFirstChild("Id") ~= nil then
if game:GetService("BadgeService"):UserHasBadge(game.Players:GetPlayerFromCharacter(player).userId, v:findFirstChild("Id").Value) ~= nil then
v:findFirstChild("ClickMe").Active = true
end end end |
|
|
|
could we see more of the script? |
|
|
Sure, but that's the only part dealing with what is messing up:3
function onSpawn(player)
if player:IsA("Model") and game.Players:GetPlayerFromCharacter(player) ~= nil then
repeat wait(.1) until game.Players:GetPlayerFromCharacter(player).Character ~= nil
wait(1)
dontHarm = Instance.new("BoolValue")
dontHarm.Name = "dontHarm"
dontHarm.Parent = player
gui = script.powerSelection:clone()
gui.Parent = game.Players:GetPlayerFromCharacter(player).PlayerGui.mainGui
children = gui.eggChoices:GetChildren()
for i, v in pairs(children) do
if v:findFirstChild("Id") ~= nil then
if game:GetService("BadgeService"):UserHasBadge(game.Players:GetPlayerFromCharacter(player).userId, v:findFirstChild("Id").Value) ~= nil then
v:findFirstChild("ClickMe").Active = true
end end end end end
game.Workspace.ChildAdded:connect(onSpawn) |
|