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

Impossible GUI to create?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Sorry if you've moved on or already solved this problem. It's sometimes difficult to find older questions that have no answers.

Your MouseClick code is doing a few things wrong. hit is always nil, since MouseButton1Click doesn't pass in any arguments. You're expecting find to return something, when you have no return statements in the find code, and you're not actually putting the tool in their BackPack, just their StarterGear. Twice. 'badgeholder' is not defined in this code. I assume you meant to use ID? Finally, you are missing a lot of ends.

ID = 158694379
badge = game:GetService("BadgeService")
player = script.Parent.Parent.Parent.Parent.Parent

function MouseClick()
    if game:GetService("BadgeService"):UserHasBadge(player.userId, ID) then
        clone = game.Lighting.GravityCoil:clone()
        clone.Parent = player.StarterGear
        clone = clone:Clone()
        clone.Parent = player.BackPack
    end
end
script.Parent.MouseButton1Click:connect(MouseClick)
Ad

Answer this question