Hello, I currently am making a Inventory System and there’s so many bugs to fix and I need help with this one, I have a delay value and its a Boolean, every time someone equips a item the value goes to true and it waits 1 second and goes to false, the equip script only works if the value is false, how do i make the delay happen after clicking this without delaying all these functions? so i want a delay after a click but it delays the functions of the click as well.
local selected = script.Parent.Parent.Parent.Handler.Selected
local location = script.Parent.Parent.Parent.Handler.Location
local player = game.Players.LocalPlayer
local character = player.Character
local LastEquipped = script.Parent.Parent.Parent.Handler.LastEquippedLight
script.Parent.MouseButton1Click:connect(function()
---- Equip Script ----
if equipped.Value ~= selected.Value then -- Just the same as the last one
print("WhenDoesThisHappen")
character.Humanoid:EquipTool(selected.Value)
script.Parent.Parent.Parent.Parent.Backpack.EquippedS.Disabled = true
script.Parent.Parent.Parent.Parent.Backpack.Unequipped.Disabled = false
script.Parent.Parent.Parent.Parent.Backpack.Equipped.Value = false
if location.Value == player.Backpack then
print("AintNoWay")
character.Humanoid:EquipTool(selected.Value)
equipped.Value = selected.Value
script.Parent.Text = "Unequip"
script.Parent.Parent.Parent.Handler.Location.Value = player
if equipped.Value:GetAttribute("Lantern") then
equipped.Value = selected.Value
script.Parent.Text = "Unequip"
character.Humanoid:EquipTool(selected.Value)
script.Parent.Parent.Parent.Parent.Backpack.Equipped.Value = true
script.Parent.Parent.Parent.Parent.Backpack.EquippedS.Disabled = false
script.Parent.Parent.Parent.Parent.Backpack.Unequipped.Disabled = true
end
end
else
---- UnEquip Script ----
if script.Parent.Parent.Parent.Handler.Equipped.Value == script.Parent.Parent.Parent.Handler.LastEquippedLight.Value then
character.Humanoid:UnequipTools()
equipped.Value = nil
script.Parent.Text = "Equip"
script.Parent.Parent.Parent.Parent.Backpack.Equipped.Value = false
script.Parent.Parent.Parent.Parent.Backpack.Unequipped.Disabled = false
script.Parent.Parent.Parent.Parent.Backpack.EquippedS.Disabled = true
script.Parent.Parent.Parent.Handler.Location.Value = player:WaitForChild("Backpack")
else
script.Parent.Parent.Parent.Handler.Location.Value = player:WaitForChild("Backpack")
character.Humanoid:UnequipTools()
equipped.Value = nil
script.Parent.Text = "Equip"
end
end
end)