我无法访问 roblox 中文本框的文本 LUA

I can't access the text of a TextBox in roblox LUA

好吧,所以我尝试了其他 Whosebugs,但我无法让它工作。
代码如下

script.Parent.MouseButton1Click:Connect(function()
  local plr = game.StarterGui.ScreenGui.title.Frame.plr
  print(plr.Text)
  local gp = game:GetService("ReplicatedStorage"):WaitForChild("GetPlr")
  gp:FireServer(plr.Text)
end);

frame.Plr 部分是文本框
当我执行 plr.Text 时,它没有获得当前输入。
希望大家多多指教
希望你今天过得愉快 :D

放置在 StarterGui 中的

UI 个元素充当模板。当他们的角色在世界中生成时,它们被复制到每个玩家的 PlayerGui 中。

您的问题是玩家已将文本放入位于 PlayerGui 中的 ui 副本中,而您正试图将该文本从模板中拉出StarterGui.

因此,在您的 LocalScript 中,尝试更新文本框的路径以指向玩家的 PlayerGui :

local PlayerService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

script.Parent.MouseButton1Click:Connect(function()
    local pg = PlayerService.LocalPlayer.PlayerGui
    local plr = pg.ScreenGui.title.Frame.plr
    print(plr.Text)

    local gp = ReplicatedStorage.GetPlr
    gp:FireServer(plr.Text)
end)