Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Bound action functions do nothing?

Asked by 5 years ago
Edited 5 years ago
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.

0
where do you bind them? have you tried print debugging? RiskoZoSlovenska 378 — 5y
0
Please notate the errors you are recieving and which lines are causing the problems. Also, have you tried debugging? RBLXNogin 187 — 5y
0
I'm not receiving any errors. It just... doesn't work for some reason BrockRocksYourSocks 48 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
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.

Ad

Answer this question