I've been trying my best to make a GUI with weapon equip options. However, the weapons in the game must be found via Badge collection. So once the badge for the weapon is found, you should be able to click on the GUI button and equip it to the players inventory, if it isn't found then the equip button should be disabled. I'm confident I'm just following the wrong guidelines to make it, any options for this?
My sad attempt ~
ID = 158694379
badge = game:GetService("BadgeService")
player = script.Parent.Parent.Parent.Parent.Parent
function find(userid, badgeid)
if game:GetService("BadgeService"):UserHasBadge(userid, badgeid) then
clone = game.Lighting.GravityCoil:clone()
clone.Parent = player.StarterGear
end
end
function MouseClick(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if (p ~= nil) then
if (find(p.userId, badgeholder.Value)) then
clone = game.Lighting.GravityCoil:clone()
clone.Parent = player.StarterGear
elseif (find(p.userId, badgeholder.Value) == false) then
hit.Parent.MouseButton1Click:remove()
end
end
script.Parent.MouseButton1Click:connect(MouseClick)

4 comments
The scripts you provided seem very reasonable but they don't appear to work. I've placed the script within a local script and then placed it within an ImageButton in my GUI. Once I entered the game and tested it, nothing happened. My profile obviously has the badge, I made sure it was the correct badge ID too. I made sure the GravityCoil was in the ReplicatedStorage as well. Does it have something
Does it have something to do with the script being local? Will it not allow badges that aren't created for the game the script is within? I was hoping that it would allow that as the game is really 5 games conjoined into one. Is there a way to fix this?
I just checked the wiki and it said that the badge service can only be used in a script.
I already knew that. But does it have something to do with the badge not being created for the game the script is in? I'm only asking because the script doesn't work.