Hello, I am doing a Difficulty Chart obby and I added a "Press R to reset" function, but the character resets even if pressing "R" while typing in the chat.
Here's the script:
local uis = game:GetService("UserInputService") local character = script.Parent local reset = false local humanoid = character:WaitForChild("Humanoid") uis.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.R then reset = true humanoid.Health = 0 else reset = false end end)
I would the function to only work when not in the chat, as it is annoying.
You can use the gameprocess parameter to disable this because the chat is technically a gui read it here:
https://devforum.roblox.com/t/how-to-disable-userinputservice-while-chatting-typing-etc/495326
this parameter checks if your input is in a gui or not
The script:
local uis = game:GetService("UserInputService") local character = script.Parent local reset = false local humanoid = character:WaitForChild("Humanoid") uis.InputBegan:Connect(function(key, gameprocess) if not gameprocess then if key.KeyCode == Enum.KeyCode.R then reset = true humanoid.Health = 0 else reset = false end end)