I cannot display the user's input in a text label

Hello! I am trying to take the user’s (number from 0 to 9) input and display it in a text label (which I will then authenticate to see if it matches with some passcodes in a table). I have created the GUI and for starters I wanted to see if I could display the number 1. That also doesn’t seem to work though. Sadly this is the first project I experiment with User Input in and the example in the roblox document doesn’t match what I am trying to achieve.

The code I have written so far is: (sorry for the lack of variables)

local keybinds = game:GetService("UserInputService")

	if input.KeyCode == Enum.KeyCode.One and game.StarterGui.TMS.BackGround.StarterScreen.Digits.Digit1.Text == "-" then
		game.StarterGui.TMS.BackGround.StarterScreen.Digits.Digit1.Text = "1"

StarterGui is what gets copied into the running game so changing it doesn’t have any effect. You want to access the PlayerGui when the game is running.

Change game.StarterGui to game.Players.LocalPlayer.PlayerGui (at all the places)

Since the StarterGui is a Roblox property, it will not show up on the client’s screen unless it is cloned to their PlayerGui. In order to modify the text label, you should locate the local player’s PlayerGui and modify it there.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Digit1 = PlayerGui.TMS.BackGround.StarterScreen.Digits.Digit1

game:GetService("UserInputService").InputBegan:Connect(function(input, processed)
	if input.KeyCode == Enum.KeyCode.One and Digit1.Text == "-" then
		Digit1.Text = "1"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.