I've run in to an issue with UserInputService:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local OpenDoor = game:GetService("ReplicatedStorage").OpenDoor
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if mouse.Target then
OpenDoor:FireServer(mouse.Target)
end
end
end)
This works fine^ But when I try and put a debounce (so players dont spam it) it breaks, this is how I did the debounce:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local OpenDoor = game:GetService("ReplicatedStorage").OpenDoor
local UIS = game:GetService("UserInputService")
debounce = true
UIS.InputBegan:connect(function(input)
if debounce == true then
debounce = false
if input.KeyCode == Enum.KeyCode.E then
if mouse.Target then
OpenDoor:FireServer(mouse.Target)
debounce = true
end
end
end
end)
Theres no errors or anything, it just doesn't work.
