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

How can I make a GUI object activate via gamepad input only when it's active?

Asked by 5 years ago
Edited 5 years ago

I've noticed a large number of console players playing my game, and some parts of it do not work properly with xbox controls according to my friend who plays on console. My previous attempt worked except for the fact that even if the GUI wasn't active if the button was pressed it would run the function/fire the event.

I'm not asking for an entire script, I am asking for what I would check/what functions I could use, I already know how to implement controls.

Thank you in advance!

EDIT:

Here's the script I tried using:

wait()
if game:GetService("UserInputService").GamepadEnabled then

    script.Parent.Text = "(Y)\n?"

end

game:GetService("UserInputService").InputBegan:connect(function(input)

    if input.UserInputType == Enum.UserInputType.Gamepad1 then
        if input.KeyCode == Enum.KeyCode.ButtonY then
            if script.Parent.Visible == true then
            if plr.QuestActive.Value ~= true then
local start = true
game.ReplicatedStorage.Quests.QuestStart:FireServer(start)
end
script.Parent.Parent.Visible = false
    if game.Players.LocalPlayer:IsInGroup(4071812) then
    plr.Character.Humanoid.WalkSpeed = 20
    else
        plr.Character.Humanoid.WalkSpeed = 16
    end
        end
        end
        end
end)

0
You should post your script and I can help with the problem. User#19524 175 — 5y

Answer this question