So i've been trying to get an input for a roblox username, and then another input with another roblox username. Then, when I press a button, it comes up with an error. Can anyone help?
local Players = game:GetService("Players")
local Plr1 = script.Parent.Parent.Plr1.Text
local Plr2 = script.Parent.Parent.Plr2.Text
local function getPlayerFromName(name)
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player.Name:lower() == name:lower() then
return player
end
end
end
script.Parent.MouseButton1Click:Connect(function(click)
local ID1 = getPlayerFromName(Plr1)
local ID2 = getPlayerFromName(Plr2)
if ID1.Value:IsFriendsWith(ID2.Value) then
print("Yes")
else
print("No")
end
end)
And then it comes up with this message: 22:15:15.245 - Players.LennyPlayzYT.PlayerGui.FriendGui.Main.Section(1).Check.LocalScript:19: attempt to index local 'ID1' (a nil value)

1 comment
But then what's the definition of 'getPlayerName'?