Hi. My ImageButton is supposed to make a frame visible and equip a tool and when you press it again it is supposed to make the frame not visible and unequip the tool. When you press it, it works, but when you press it again, it doesn't do anything. The frame is still visible and the tool is still equipped. The local script inside of the ImageButton.
local player = game.Players.LocalPlayer
local Backpack = player:WaitForChild("Backpack")
local FindTool = Backpack:FindFirstChild("MagnifyingGlass")
local frame = script.Parent.Parent.Star
script.Parent.MouseButton1Click:Connect(function()
if frame.Visible == false then
if player and player.Character then
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
local tool = FindTool
if tool then
humanoid:EquipTool(FindTool)
frame.Visible = true
print('equip')
elseif
frame.Visible == true then --frame is visible then
frame.Visible = false
humanoid:UnequipTools()
print("unequip")
end
end
end
end
end)
There are no errors and the print("unequip") doesn't work either. I tried doing "humanoid:UnequipTools(FindTool)" but that didn't work either. Thanks!
