Sometimes UIS just flat out ignores the F input. My keyboard works fine, I have tested this.
Printing to the console, UIS detects other inputs. Every other input. Typing F in the command bar, moving back to the game, and still no input being detected. (Proving the F key still works) This happens 1/10 times I start the game, and sometimes even outside of studio. I am at a loss of ideas.
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local rp = RaycastParams.new()
rp.CollisionGroup = "Look"
rp.RespectCanCollide = true
script.Parent.FlashlightPrimary.WeldConstraint.Enabled = false
script.Parent.Parent:WaitForChild("RopeConstraint").Visible = false
game:GetService("RunService").RenderStepped:Connect(function()
local mpos = game:GetService("UserInputService"):GetMouseLocation()
local unitRay = workspace.CurrentCamera:ViewportPointToRay(mpos.X, mpos.Y)
local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * 10000, rp)
if ray then
script.Parent.Flashlight:PivotTo(CFrame.lookAt(char.Head.Position, ray.Position))
end
end)
--start of the bugged code. the rest of this page is irrelevant but included for the sake of this article
print("listening") --always prints.
UIS.InputBegan:Connect(function(key, gpe)
print("button", key.KeyCode, gpe) --always prints, unless F is pressed while the bug is occuring.
if gpe then return true end
if key.KeyCode == Enum.KeyCode.F or key.KeyCode == Enum.KeyCode.ButtonY then
script.Toggle:FireServer()
end
end)
game.Players.LocalPlayer.PlayerGui:WaitForChild("General").Hotbar.Flashlight.Keybind.ImageLabel.TouchTap:Connect(function()
script.Toggle:FireServer()
end)
The console ALWAYS prints âlisteningâ, and ALWAYS prints the other inputs. Nothing prints when F is pressed if the bug occurs.
Try to isolate your issue, create a new empty place with that part of the script thatâs having problems. This could be an engine bug, or it could be caused by something else in your game.
Iâm not totally sure, but this may be happening because GameProcessedEvent (which I have no idea what that even is lol) may be true, causing your if gpe then return true end to trigger.
This is because your character isnât fully loaded, and the F key specifically is revealing that.
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") --magic pause
--
--
You donât need the character and its humanoid to be loaded for input detection to work, unless itâs a local script under the character, but in that case, the script wonât run until the character spawns, and thereâs still no need to wait for the humanoid.
That just seems to be a weird issue on their deviceâs end or Roblox API rather than a problem with the script. Thereâs no logical reason why only the F key not work when all the other keys work perfectly fine.
@VintageDegenerate This issue could be caused by a studio shortcut that prevents UIS from working. The F key is, by default, bound to the âZoom Toâ shortcut function.
Try going to File > Studio Settings > Studio > Advanced and unchecking âRespect Studio shortcuts when the game has focus.â This should resolve the issue.
Roblox can miss keyboard input, specifically the F key and possibly other keys, if the character isnât fully loaded yet. This mostly happens due to the timing mismatch between input binding and the characterâs load state. If youâre using something like local char = player.Character, and itâs nil when the F key is pressed, your handler might silently fail or skip logic. Using WaitForChild(âHumanoidâ) can prevent that completely. Even adding a task.wait() after that helps ensure stability.
Did you think that was a wild guess? Iâve run into this, and this was the outcome of some serious research. Go look for yourself⌠youâre assuming.
Well, that would explain the assuming. This is not a debate. Take it or leave itâŚ
I canât say for sure this is his problem, but it sure sounds familiar.
I cannot believe it until you show me proof that it can happen on the live server, or provide an official documentation page stating that UserInputService requires the character to be fully loaded to function correctly.
For now, this issue only occurs in Studio and has been encountered multiple times in the past with the keys F, I, and O, which are all bound to Studio shortcuts for zooming to, zooming in, and zooming out.
Well I fixed it before I went past that.. Sound like you know this is real, what proof do you need other than âencountered multiple times in the past with the keys Fâ
This is for trying to answer questions, not baiting. Now youâre assuming I didnât read all that.
I did say and possibly other keys. âAlso, if it were true, it would be specified in the documentationâ
Ya, I found that and more⌠Again, go research for yourself. Youâre being rude, sir. Iâm done, save the reply.
If this problem occurs again, Iâll reply here. I am not sure what caused the occurrence in-game, though that was a little while ago so I presume it was fixed by me at some point.