UserInputService.InputBegan refuses to work

  1. What do you want to achieve? I want to achieve rotation of the part in my sussy placement system

  2. What is the issue? UserInputService.InputBegan refuses to work at all. I’ve tried to add an “print” function, making sure UserInputService works.

  3. What solutions have you tried so far? Looked for solutions in Developer Hub: none. Looked for solutions in here as well - none as well.

Here’s my totally not terrible code so far:

uis.InputBegan:Connect(function(Input,GameProcessed)
	if Input.UserInputType == Enum.KeyCode.E then
		if rotation <= 180 then
			rotation += 15
			print(rotation)
		end
	elseif Input.UserInputType == Enum.KeyCode.Q then
		if rotation >= -180 then
			rotation -= 15
			print(rotation)
		end
	end
end)
1 Like

Where is the script located and what type of script is it (module,server or local)

Change Input.UserInutType to Input.KeyCode

The script is located at a Tool, and is a LocalScript.

E is not a valid member of "Enum.KeyCode.E"
Am i doin’ something wrong?

Edit: just realized i’ve replaced Enum with Input instead of replacing Input.UserInputType to Input.Keycode :bruh:

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(key,GameProcessed)
	if GameProcessed then return end
	if key.KeyCode == Enum.KeyCode.E then
		print("clicked E")
	end
end)

this worked fine for me. Can you show the full script?

local value = script.Parent.Handle.Value
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("BuildEvent")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local prewiews = rs:WaitForChild("Prewiew")
local prewiew = prewiews:FindFirstChild("PrewiewBrick") -- prewiew name
local clone = prewiew:Clone()
local uis = game:GetService("UserInputService")
local rotation = 0

mouse.Move:Connect(function()
	if value.Value == true then
		clone.Parent = workspace
		clone.Position = Vector3.new(0,0,0) -- reset position
		clone.Position = Vector3.new(mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z)
		clone.CFrame = CFrame.Angles(0,math.rad(rotation),0)
	end
end)

script.Parent.Equipped:Connect(function()
	value.Value = true
end)

script.Parent.Unequipped:Connect(function()
	value.Value = false
	clone.Parent = rs
end)

uis.InputBegan:Connect(function(Input,GameProcessed)
	if Input.KeyCode == Enum.KeyCode.E then
		if rotation <= 180 then
			rotation += 15
			print(rotation)
		end
	elseif Input.KeyCode == Enum.KeyCode.Q then
		if rotation >= -180 then
			rotation -= 15
			print(rotation)
		end
	end
end)

script.Parent.Activated:Connect(function()
	event:FireServer(Vector3.new(mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z),rotation)
end)

Yes this script that you have written also worked for me

It’s Input.KeyCode, not Input.UserInputType.

This code should be like this:

Input.KeyCode ==
Enum.KeyCode.E