Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I do a keydown event that doesn't count when the play is typing?

So I made this custom jump thing but it still goes when somebody presses space while typing. How do I fix this?

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local human = char:WaitForChild("Humanoid")
local inputservice = game:GetService("UserInputService")

coolDown = false
local jumpvelocity = 75


--Cancels out default jump
human.Changed:connect(function()
	human.Jump = false
end)

animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://513291588"
animationTrack = plr.Character.Humanoid:LoadAnimation(animation)

--Jumps while pressing space while typing... Add your own debounce too.
inputservice.InputBegan:connect(function(inputobject)
	if inputobject.KeyCode == Enum.KeyCode.Space and coolDown == false then
		animationTrack:Play()
		coolDown = true
		char.Torso.Velocity = Vector3.new(0,jumpvelocity,0)
		wait(5)
		coolDown = false
	end
end)

1 answer

if inputservice:GetFocusedTextBox() == nil then
--code and stuff
end

This discussion is preserved as it was. New answers, comments, and votes are closed.