Im making this script where when this function is called, it writes the text on the text label. That is working, the problem is: its being called twice when its supposed to be called once.
function lookItem(content) -- Here it is called twice, making the text duplicated and weird
script.Parent.InventoryFrame.EquipFrame.LookText.Visible = true
useButton.Visible = false
lookButton.Visible = false
dropButton.Visible = false
script.Parent.InventoryFrame.EquipFrame.LookText.Text = ""
wait(0.3)
for i = 1, #content do
script.Parent.InventoryFrame.EquipFrame.LookText.Text = script.Parent.InventoryFrame.EquipFrame.LookText.Text..content:sub(i, i)
if content:sub(i, i) == "." or content:sub(i, i) == "!" or content:sub(i, i) == "?" then
wait(0.5)
elseif content:sub(i, i) == "," then
wait(0.4)
end
wait(0.03)
end
wait(1.5)
script.Parent.InventoryFrame.EquipFrame.LookText.Text = ""
script.Parent.InventoryFrame.EquipFrame.LookText.Visible = false
useButton.Visible = true
lookButton.Visible = true
dropButton.Visible = true
end
function addItem(ItemName, value)
local debounce = false
local ItemButton = script.Parent.InventoryFrame.ItemsFrame.ItemButton:Clone()
local ItemButtonb = miscFrame.Items.ItemButton:Clone()
ItemButton.Visible = true
ItemButton.Name = ItemName
ItemButton.Text = "* "..itemsModule[ItemName].name
ItemButtonb.Visible = true
ItemButtonb.Name = ItemName
ItemButtonb.Text = "* "..itemsModule[ItemName].name
repeat
ItemButton.Parent = itemFrame
until ItemButton.Parent == itemFrame
repeat
ItemButtonb.Parent = miscFrame.Items
until ItemButtonb.Parent == miscFrame.Items
ItemButton.MouseButton1Click:Connect(function()
if SelectedItem ~= nil then
itemFrame.Parent.EquipFrame.LookText.Visible = false
useButton.Visible = true
lookButton.Visible = true
dropButton.Visible = true
SelectedItem.BackgroundTransparency = 1
end
SelectedItem = ItemButton
SelectedItem.BackgroundTransparency = 0
end)
ItemButtonb.MouseButton1Click:Connect(function()
SelectedItem = ItemButtonb
useItem(SelectedItem,ItemName)
ItemButton:Destroy()
SelectedItem = nil
end)
useButton.MouseButton1Click:Connect(function()
if SelectedItem ~= nil then
useItem(SelectedItem)
ItemButtonb:Destroy()
SelectedItem = nil
end
end)
dropButton.MouseButton1Click:Connect(function()
if SelectedItem ~= nil then
SelectedItem:Destroy()
ItemButtonb:Destroy()
SelectedItem = nil
end
end)
lookButton.MouseButton1Click:Connect(function()
if SelectedItem ~= nil and debounce == false then
debounce = true
lookItem(itemsModule[SelectedItem.Name].look) --Here it is called once
task.wait(1)
debounce = false
end
end)
end