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

Input Began / Input Ended Not Running Action?

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.

1 comment

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

1 answer

✓ Accepted answer

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)

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