So in this game im making it so you can pick up items but idk how to make it so you can’t press a keybind and right click at the same time. When this happens the item gets duplicated and they would have 2x. How would i make this not happen? Heres the script
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
UIS.InputChanged:Connect(function(input)
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.name
else
PickupInfoGui.Adornee = nil
end
end
end)
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
end)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if input.UserInputType == Enum.UserInputType.MouseButton1 and input.KeyCode == Enum.KeyCode.F then return end
If right click and the F key are pressed, the script will not run.
local allowed = true -- Don't need to change this
local blockduration = 0 -- Set to 0 if not: Choose a duration to disable for
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
UIS.InputChanged:Connect(function(input)
if allowed == true then
allowed = false
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.name
else
PickupInfoGui.Adornee = nil
end
end
wait(blockduration)
allowed = true
end
end)
UIS.InputBegan:Connect(function(input, processed)
if allowed == true then
allowed = false
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
wait(blockduration)
allowed = true
end
end)
local allowed = true -- Don't need to change this
local blockduration = 0 -- Set to 0 if not: Choose a duration to disable for
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
UIS.InputChanged:Connect(function(input)
if allowed == true then
allowed = false
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.name
else
PickupInfoGui.Adornee = nil
end
end
wait(blockduration)
allowed = true
end
end)
UIS.InputBegan:Connect(function(input, processed)
if allowed == true then
allowed = false
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
wait(blockduration)
allowed = true
end
end)
debounce it so if the event is fired set debounce to true then wait a set amount of time set debounce back to false
sumn like this
local debounce = false
UIS.InputBegan:Connect(function(input, processed)
if not debounce then
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
debounce = true
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
wait(5)
debounce = false
end
end)
local allowed = true -- Don't need to change this
local blockduration = 0 -- Set to 0 if not: Choose a duration to disable for
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
UIS.InputChanged:Connect(function(input)
if allowed == true then
allowed = false
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.name
else
PickupInfoGui.Adornee = nil
end
end
wait(blockduration)
allowed = true
end
end)
UIS.InputBegan:Connect(function(input, processed)
if allowed == true then
allowed = false
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
wait(blockduration)
allowed = true
end
end)
local allowed = true -- Don't need to change this
local blockduration = 0 -- Set to 0 if not: Choose a duration to disable for
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
UIS.InputChanged:Connect(function(input)
if allowed == true then
allowed = false
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.target
PickupInfoGui.Adornee = item
PickupInfoGui.ObjectName.Text = item.name
else
PickupInfoGui.Adornee = nil
end
end
wait(blockduration)
allowed = true
end
end)
UIS.InputBegan:Connect(function(input, processed)
if allowed == true then
allowed = false
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.F then
if mouse.Target and mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 30 then
PickupItem:FireServer(item)
end
end
end
end
wait(blockduration)
allowed = true
end
end)