I want to fix a bug, which lets players play the audio when the 'H' key is down and up by using UserInputState. I put it inside a function as an argument. However, the audio does not play when I press 'H' key. Perhaps I should create a separate function for this case? If you are wondering, this problem is involving ContextActionService.


local ContextAction = game:GetService("ContextActionService")

local function KeyPress(InputBegan)
		 if InputBegan == Enum.UserInputState.Begin then		
			game.Workspace.Sound:Play()
		 end		
	end
		ContextAction:BindAction("State", KeyPress, false, "h")	

2 comments

0

You need to change "State" to "Up", "Down" or "Both"

0

Use Enums.