Need Help With Simple Local Script

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

StarterCharacter:
image

StarterPlayer:
image

Maybe its in startercharacter and starter player at the same time

image
I printed the parent of the scripts and it says it is inside my character model. When I check I don’t see the duplicate

Maybe because you’re printing it 2 time there ?

print(print("Here"))

So it should be like this

print("Here")

Still doesn’t work.
image
Why is it that the first print tells me the line of code but the second print just says Client

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.
Capture

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)

Maybe it is something on my end I will research more. Thank you.

1 Like

Still doesn’t work don’t know what the problem is but I will research more

I figured out the problem. thakn you --------------------------

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.