Hi, i want to make a machine that takes in an item when you press E and then works for some seconds and gives out another item. But somehow i can still spam E and its taking in more items. SHouldnt the debounce prevent this?
local rs = game:GetService("ReplicatedStorage")
local s = game:GetService("ServerStorage")
local sg = rs:WaitForChild("ShowGui")
local input = game:GetService("UserInputService")
local ti = rs:WaitForChild("TakeItem")
local giveitem = rs:WaitForChild("GiveItem")
local d = false
local c = script.Parent.ClickDetector
local a = 0
local e = false
c.MouseHoverEnter:Connect(function(plr)
local mouse = plr:GetMouse()
sg:FireClient(plr, "Desk", "Open", false)
c.MouseHoverLeave:Connect(function(plr)
sg:FireClient(plr, "Desk", "Close", false)
end)
--if d == false then
-- d = true
mouse.KeyDown:Connect(function(key)
if key == "e" and mouse.Target.Name == "Board" then
if d == false then
d = true
c.MaxActivationDistance = 0
if ti:InvokeClient(plr, "Metal") == true then
script.Parent.Model3.gui.BillboardGui.Enabled = true
wait(5)
script.Parent.Model3.gui.BillboardGui.Enabled = false
local found = s.Items:FindFirstChild("Duct Tape"):Clone()
local item = Instance.new("ImageButton", workspace)
item.Name = found.Name
item.Size = UDim2.new(0,35,0,35)
item.Position = UDim2.new(0,11,0,11)
item.Image = found.Image
item.BackgroundTransparency = 1
item.BorderSizePixel = 0
item.ZIndex = 3
giveitem:InvokeClient(plr, item)
end
else
print("Not enough Metal")
end
c.MaxActivationDistance = 20
d = false
end
print("Error")
print(key)
print(mouse.Target.Name)
c.MaxActivationDistance = 20
d = false
end)
end)
--end

3 comments
I would check to see if the if statement on line 30 is working. If you have any additional questions comment below my answer.
No problem!
You’re trying to capture user input from the server, which is not okay.