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

How do you change MouseButton1Up to a gamepad equivelant (Enum.KeyCode.ButtonB)?

Asked by 9 years ago

I need the sword script to be changed from this:

--rbxsig%aoxvdm1aPjaZNWfciK/Pr0xTiQSMTYPK6DeYzUBftM3ktWksFxD/qPfCrisawJWUgizm/pahcvio8hGdfVGRiDrzgV+Eu4mePmGNQTrNP1WKW+gHElJt9nBVEWptENhA5JCXALEN65aM6HLKdEaWvEOtAKhSF2Y2nJcuyixzj58=%
--rbxassetid14476%
local Tool = script.Parent;

enabled = true
function onButton1Down(mouse)
    if not enabled then
        return
    end

    enabled = false
    mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"

    wait(.5)
    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    enabled = true

end

function onEquippedLocal(mouse)

    if mouse == nil then
        print("Mouse not found")
        return 
    end

    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end


Tool.Equipped:connect(onEquippedLocal)

To a working gamepad equivelant. (Can be any button, preferably ButtonR2)

1 answer

Log in to vote
0
Answered by 9 years ago

Found it out myself after a little while of poking around. Here it is for all of those who want to make games with gamepads!

--rbxsig%aoxvdm1aPjaZNWfciK/Pr0xTiQSMTYPK6DeYzUBftM3ktWksFxD/qPfCrisawJWUgizm/pahcvio8hGdfVGRiDrzgV+Eu4mePmGNQTrNP1WKW+gHElJt9nBVEWptENhA5JCXALEN65aM6HLKdEaWvEOtAKhSF2Y2nJcuyixzj58=%
--rbxassetid14476%
local Tool = script.Parent;

enabled = true
function onButtonR2Down(mouse)
    if not enabled then
        return
    end

    enabled = false
    mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"

    wait(.5)
    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    enabled = true

end

function onEquippedLocal(mouse)

    if mouse == nil then
        print("Mouse not found")
        return 
    end

    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    mouse.ButtonR2:connect(function() onButtonR2Down(mouse) end)
end

Tool.Equipped:connect(onEquippedLocal)
Ad

Answer this question