UserInputService not working in tools

I’m not sure if UIS is even supposed to work in tools, but I tried using it in a local script for one of my tools and it didn’t seem to work.

Is it possible to use UIS in tools? And If so, why Is this not working?

local basePianoMarkDistance = -7
local pianoMarkMultiplier = 0

function pianoMarkPosition()
	pianoMark.CFrame = Player.Character.PrimaryPart.CFrame * CFrame.new(0, -4, basePianoMarkDistance + pianoMarkMultiplier)
end

UserInputService.InputBegan:Connect(function(input, gpe)
	if input == Enum.KeyCode.Y and not  gpe and pianoMarkMultiplier ~= 100 then
		print("a")
		pianoMarkMultiplier += 1
	elseif input == Enum.KeyCode.H and not gpe and pianoMarkMultiplier ~= 0 then
		print("b")
		pianoMarkMultiplier -= 1
	end
end)

Tool.Equipped:Connect(function()
	UserInputService.MouseIcon = MOUSE_ICON
	
	game:GetService("RunService").Heartbeat:Connect(pianoMarkPosition)
end)

Tool.Unequipped:Connect(function()
	UserInputService.MouseIcon = "rbxassetid://1"
end)

do

input.KeyCode

instead of

input
1 Like

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