The debounce works fine when the local script in in StarterPlayerScripts but when I add it to StarterCharacterScripts it bugs out.
local UserInputService = game:GetService("UserInputService")
local debounce = true
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if debounce then
debounce = false
print(print("Here"))
wait (1)
debounce = true
end
end
end)
When the script is in startercharacterscripts it runs twice and this messes up the debounce. I need help figuring out why it runs twice when the script is located in starter characterscripts
I don’t know… i just tried to copy past the code into 2 local script, one in starter character and one in starter player, one print “Test1” the other print “Test2” and it work fine.
local UIS = game:FindService('UserInputService') or game:GetService("UserInputService")
local debounce = true
UIS.InputBegan:Connect(function(Key, Gpe)
if Gpe then return end
if Key.UserInputType == Enum.UserInputType.Keyboard then
if debounce then
debounce = false
print('Here')
task.wait(1)
debounce = true
else
print('cooldown active')
end
end
end)