I tried to use for i,v in pairs, but my code keeps looping through the players, and every time it does this, it repeats "error"- until it gets to a matching player. I know this is supposed to happen; but is there an easier way?
Commands.warn = function(Sender,Arguments)
local Username = Arguments[1]
table.remove(Arguments, 1)
local Message = table.concat(Arguments, " ")
if Username == string.lower(Sender.Name) then
fWarn(Sender,"Error: You can't warn yourself.",true,"rbxassetid://26399276")
else
for i,v in pairs(game.Players:GetChildren()) do
if string.lower(v.Name) == Username then
fWarn(Sender,"Sucessfully Warned "..v.Name.."!",true,"rbxassetid://377245168")
fWarn(v,"You have been warned by"..Sender.Name..": "..Message,true,"rbxassetid://377245168")
else
fWarn(Sender,"Error.",true,"rbxassetid://26399276")
end
end
end
end
Thanks in advance.
For some context: I'm trying to make it so that when an admin says !warn {Player} {Reason}, that function will fire. I already have the commands working, I just need a better way of finding the player, one that does not involve looping through them all.

1 comment
can u accept my answer?