Side note, but connect is deprecated
Also I believe the reason why it’s erroring is cause you’re attempting to find a value of a string inside the Players service, which won’t work
There’s been a post relevant to this I believe, you can check that out or try out this script:
local function GetPlayerFromString(Name)
print(Name)
for _, Player in pairs(game.Players:GetPlayers()) do
print(Player.Name)
if Player.Name:lower() == Name:lower() then
print("Found the target")
return Player
end
end
end
script.Parent.MouseButton1Click:connect(function()
local target = script.Parent.Parent.WarnUserBox.Text
print(typeof(target)) --This would be a string
local reason = script.Parent.Parent.Reason.Text
local TargetPlayer = GetPlayerFromString(target)
print(TargetPlayer)
if TargetPlayer then
local TargetGui = TargetPlayer:WaitForChild("PlayerGui")
TargetGui.Reason.Text = reason
TargetGui.ZiaWarnMsg.Visible = true
print("Warned User.")
else
print("Not a valid name.")
end
end)