Code isn't running at all?

What’s up, title is self explanatory. Here’s the code:

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.CharacterAdded:Wait() or player.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid.Animator

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	
	if input.KeyCode == Enum.KeyCode.F then
		print("Holding")
	end
end)

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end

	if input.KeyCode == Enum.KeyCode.F then
		print("Released")
	end
end)
1 Like

Put a print at the top of the script to know when it runs.

Some common checks that you could do, is hit play in studio, and see if you can locate the script that should be running. Verify that it is the type of script you expect and that it will run in the context that it is in. Verify that it is not disabled.

In your case, you’ll probably expect to see it in Players.[player].PlayerScripts as a LocalScript

Thank you for your reply.

I put a print at the top, however it seems the script isn’t running at all, as it isn’t printing. Also, the script is still enabled, and for some reason isn’t working which is pretty strange. I have the script in StarterPack, as it’s going to be a combat script, and scripts I normally place in StarterPack do work, it’s just this one in particular for some reason. I even tried opening the script in another studio and the code won’t run.

put the script in starterplayer, also make sure that it is a localscript

Even so, it still doesn’t work. I just tried placing a print statement above defining the player and its components, and that works, so it seems that everything after I define the player just breaks the script?

i just noticed you have two input begans, aside from that, sandwich the line that declares character with two prints and see if both show

Thank you, I totally was oblivious to the silly mistake of using two inputbegans, LOL.

np ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

1 Like

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