Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Local Badge script error?

Asked by 9 years ago

I've been trying my best to make a GUI with weapon equip options. However, the weapons in the game should only be accessed if the player has the certain badge collected. So once the badge for the weapon is found, you should be able to click on the GUI button and equip it to your 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?

The following script doesn't work properly for some odd reason:

local ID = 158694379
local badge = game:GetService("BadgeService")
local player = game.Players.LocalPlayer

function find(userid, badgeid)
    if badge :UserHasBadge(userid, badgeid) then
        local clone = game.ReplicatedStorage.GravityCoil:clone()
        local clone2 = game.ReplicatedStorage.GravityCoil:clone()
        clone.Parent = player.Backpack
        clone2.Parent = player.StarterGear
    else
        script.Parent.MouseButton1Click:Destroy()
        --script.Parent.BackgroundColor3 = Color3.New(.5, .5, .5)
    end
end

script.Parent.MouseButton1Click:connect(function() find(player.userId, ID) end)

Answer this question