So… I’ve been working on an game and I made an GUI and scripted that it changes your team if you have a specific badge. But it didnt work can anyone help me with it?
local player = script.Parent.Parent.Parent.Parent.Parent
local BadgeService = game:GetService("BadgeService")
local Id = 123 -- Badge ID
script.Parent.MouseButton1Click:connect(function()
if BadgeService:UserHasBadgeAsync(player.UserId, Id) then
player.Team = game.Teams:FindFirstChild("Example Team") -- The team
player:LoadCharacter()
else
warn("Player don't have badge")
end
end)
script.Parent.MouseButton1Click:connect(function()
print("clicked", player)
if BadgeService:UserHasBadgeAsync(player.UserId, Id) then
player.Team = game.Teams:FindFirstChild("Example Team") -- The team
player:LoadCharacter()
else
warn("Player don't have badge")
end
end)
Try changing the function to this, tell me what it prints out in the output.
I just tried it and it works for me. Make sure your player variable actually points to your player.
So then what is the problem? It is working. Since the output is “Player don’t have badge” that means the player doesn’t own the badge so it won’t change their team.
Because you don’t own the badge. You said you want the player to have a specific badge to change their team. If they don’t have the badge then it won’t change the team. You do not own the badge, therefore you can’t change your team. I don’t see what the problem you have is. You are saying it isn’t working because it won’t change your team, but you are also saying you want the user to have a specific badge.
Look I made something called alpha testers and I want that all that play my game during the alpha gets a badge (I already made the script it works) and now I wanned to make that these guys can get a cool team only for them. And btw I have the badge cause of the script I’ve made. I’m pretty new to scripting that’s why I asked something like that inside of that forum I really appreciate your help but anything is wrong with the badge stuff I’ll try to find out how to fix the bug.
And Have a nice day and thanks for the help.
Did you change the variables for the badge ID local Id = 123 -- Badge ID and the team game.Teams:FindFirstChild("Example Team") -- The team?
also make sure you turned on access to roblox API services in game settings