Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Impossible GUI to create?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.