UserInputService Script

Hello!

I am having trouble with this script I made… It is located in a part in a custom character labeled StarterCharacter in the StarterPlayer folder. The script is a local script and there are no errors in the output.

local sp = script.Parent    --Ignore 
local Bullet = game.ReplicatedStorage["Bullet"]  --Ignore
local folder = game.Workspace.Bullets  --Ignore


local UIS = game:GetService("UserInputService")


local function onInputBegan(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.F then
		print("Script works")
	end
end

UIS.InputBegan:Connect(onInputBegan)

Thanks!
(And note I’m not that great with scripting so sorry in advance)

UserInputType can determine the platform in which the player is running the game. Instead, use KeyCode which is a list of all keyboard keys.

local function onInputBegan(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.F then
		print("Script works")
	end
end

UIS.InputBegan:Connect(onInputBegan)

Hello thanks for responding.

I changed it to keycode yet it still does not work. No errors in the output.

Sorry, I didn’t completely read your post:

LocalScripts do not run on StarterPlayer nor Workspace, why you don’t just parent it to StarterPlayerScripts?

Yes that actually makes more sense. I parented the script to StarterPlayerScripts though the script still does not work…

Are you sure? I tested it and everything works fine.
image
image

Ya… That is very weird. (The script is called Shoot)