Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] Bound action functions do nothing?

function moveMenu(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then
		if GuiService.SelectedObject ~= nil then
			if (inputObj.KeyCode == Enum.KeyCode.Left or inputObj.KeyCode == Enum.KeyCode.A) then
				changeAngleOffset(-45)
			elseif (inputObj.KeyCode == Enum.KeyCode.Right or inputObj.KeyCode == Enum.KeyCode.D) then
				changeAngleOffset(45)
			end
			
			selectSound:Play()
		end
	end
end

function thumbstickMoveMenu(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then
		local pos = inputObj.Position
		
		if GuiService.SelectedObject ~= nil then
			changeAngleOffset(45 * math.sign(pos.X))
		end
		
		selectSound:Play()
	end
end

These functions are supposed to make a GUI rotate 45 degrees in a given direction with the arrow keys and left thumbstick, respectively.

However, while both of them are in the console's ActionBindings list, they don't do anything, and nothing is showing up in the output, so I'm not sure what the problem is.

3 comments

0

where do you bind them? have you tried print debugging?

0

Please notate the errors you are recieving and which lines are causing the problems. Also, have you tried debugging?

0

I'm not receiving any errors. It just... doesn't work for some reason

1 answer

UserInputService.InputBegan:Connect(function(inputObj, processed)
	if menuOpen == true and GuiService.SelectedObject ~= nil then
		if (inputObj.KeyCode == Enum.KeyCode.Left or inputObj.KeyCode == Enum.KeyCode.A) then
			changeAngleOffset(-45)
		elseif (inputObj.KeyCode == Enum.KeyCode.Right or inputObj.KeyCode == Enum.KeyCode.D) then
			changeAngleOffset(45)
		end
	end
end)

UserInputService.InputChanged:Connect(function(inputObj, processed)
	if menuOpen == true and GuiService.SelectedObject ~= nil then
		if inputObj.KeyCode == Enum.KeyCode.Thumbstick1 then
			local pos = inputObj.Position
			local xx = pos.X
			
			if (xx == 1 or xx == -1) then
				changeAngleOffset(45 * math.sign(xx))
			end
		end
	end
end)

I eventually decided to use UserInputService instead. That fixed the problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.