I currently have this. I tried using Game.Players.LocalPlayer with a local script but got the same error, tried to concatenate the variable. I don't know.
local justice1 = game.Workspace.justice.SurfaceGui.Text local justice2 = game.Workspace.justice2.SurfaceGui.Text local justice3 = game.Workspace.justice3.SurfaceGui.Text local plaintiff1 = game.Workspace.hobruh.plaintiff.SurfaceGui.Text local plaintiff2 = game.Workspace.hobruh.plaintiff2.SurfaceGui.Text local plaintiff3 = game.Workspace.hobruh.plaintiff3.SurfaceGui.Text local defendant1 = game.Workspace.hobruh.defender.SurfaceGui.Text local defendant2 = game.Workspace.hobruh.defender2.SurfaceGui.Text local defendant3 = game.Workspace.hobruh.defender3.SurfaceGui.Text local name = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent local justice = script.Parent.Parent.Justice local plaintiff = script.Parent.Parent.Prosecutor local defendant = script.Parent.Parent.Defender function SubmitDetails() justice1.Text = justice.Text justice2.Text = justice.Text justice3.Text = justice.Text plaintiff1.Text = plaintiff.Text plaintiff2.Text = plaintiff.Text plaintiff3.Text = plaintiff.Text defendant1.Text = defendant.Text defendant2.Text = defendant.Text defendant3.Text = defendant.Text local hint = Instance.new('Hint', game.Workspace) hint.text = name.."has just edited the case details" end script.Parent.MouseButton1Down:connect(SubmitDetails) -- hierarchy -- - game -- -- Teams -- --- (team) -- ---- MenuGuis -- ----- Frame -- ------ CourtBase -- ------- Submit -- -------- SubmitDetails (Script)
There's not much explanation needed here. I assume you are working with LocalScripts, which is the logical thing to do when working with GuiObjects of anykind. If yes, the player that clicks the TextButton is the LocalPlayer, because it's the only player the local script is running for.
local player = game:GetService('Players').LocalPlayer print(player:GetFullName()) --> Players.PlayerName
After getting the player, all you would have to do is refer to the variable later on in the script. For instance, in your code, you would do something like this.
local player = game:GetService('Players').LocalPlayer function SubmitDetails() justice1.Text = justice.Text justice2.Text = justice.Text justice3.Text = justice.Text plaintiff1.Text = plaintiff.Text plaintiff2.Text = plaintiff.Text plaintiff3.Text = plaintiff.Text defendant1.Text = defendant.Text defendant2.Text = defendant.Text defendant3.Text = defendant.Text local hint = Instance.new('Hint', game.Workspace) hint.text = player.Name.."has just edited the case details" end