Touch player to display username to text ui

  1. What do you want to achieve? When press the player gets player’s name to text ui.

  2. What is the issue? When press the player gets player’s name but cant.

  3. What solutions have you tried so far? Yep. But no solutions.

local player = game.Players.LocalPlayer
local button = script.Parent.TextButton
local username = script.Parent.AssignFrame.Username

button.MouseButton1Click:Connect(function(player)
	local username = player.Name
	script.Parent.AssignFrame.Username.Text = player.Name
end)

https://gyazo.com/5436736a401e7d9a84e5abcf62d0650c

1 Like

Maybe because you have 2 “local username” and 2 “player and local player”. If I remember correctly when you declare a value again it makes the script just do nothing.

Fixed code here:

local LocalPlayer = game.Players.LocalPlayer
local button = script.Parent.TextButton
local Username_Frame = script.Parent.AssignFrame.Username

button.MouseButton1Click:Connect(function()
	local PlayerUsername = LocalPlayer.Name
	Username_Frame.Text = PlayerUsername 
end)

If you are trying to replace a local value, instead of doing local Value = false, do Value = false.

2 Likes

Do I have to make TextButton for this? I wanna delete textbutton.

1 Like

image
Because of this.

1 Like

Yes but this is not the only way to do it, the button is a way to call an event inside of the script with .MouseButton1Click, if you are looking to press the button “Submit” declare the local button = “the submit button ubication in the frame”, example: script.Parent (Just put the script inside the button).

2 Likes

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