What do you want to achieve? When press the player gets player’s name to text ui.
What is the issue? When press the player gets player’s name but cant.
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)
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.
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).