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

Input Began / Input Ended Not Running Action?

Asked by 2 years ago

I'm trying to make a custom playerlist and I made an Input Began / Input Ended Function which is when you press tab the playerlist is visible.

[This is tricky because there are no errors.]

Code:

local PlayerList = game.StarterGui:WaitForChild("PlayerList")
local ScrollingFrame = PlayerList:WaitForChild("ScrollingFrame")
local Player = game.Players.LocalPlayer
local Template = game.StarterGui.PlayerList.Template
local Frame = game.StarterGui.PlayerList.Template:Clone()

-- UI Script

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Tab then
        PlayerList.Enabled = true
        ScrollingFrame.Visible = true
    end
end)

UIS.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Tab then
        PlayerList.Enabled = false
        ScrollingFrame.Visible = false
    end
end) 

Please help me resolve this issue.

0
seems like you're changing the gui in StarterGui instead of the players gui so its not going to do anything https://developer.roblox.com/en-us/api-reference/class/PlayerGui enzotinman1 23 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

try this

local PlayerList = game.Players.LocalPlayer.PlayerGui:WaitForChild("PlayerList")
local ScrollingFrame = PlayerList:WaitForChild("ScrollingFrame")
local Player = game.Players.LocalPlayer
local Template = Player.PlayerGui.PlayerList.Template
local Frame = Player.PlayerGui.PlayerList.Template:Clone()
local UIS = game:GetService("UserInputService")

-- UI Script

UIS.InputBegan:Connect(function(Input, gameprocessed)
    if Input.KeyCode == Enum.KeyCode.Tab then
        PlayerList.Enabled = not PlayerList.Enabled
        ScrollingFrame.Visible = not ScrollingFrame.Visible
    end
end)

Ad

Answer this question