The problem area is lines 16-22, where it won't find the player that I'm talking about. The command I would use would be /awarp 001 CardboardRocks to award 1 PP to CardboardRocks. Any ideas as to why this isn't working?
keyword = "/awarp" local PointsService = Game:GetService("PointsService") game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() pointsToAward = PointsService:GetAwardablePoints() player.Chatted:connect(function(msg) if string.find(msg:lower(), keyword) then print("Found "..keyword) a = msg:sub(8, 11) print(a) c = msg:sub(12, msg:len()) playerschildren = game.Players:GetChildren() for i, v in pairs(playerschildren) do if c == v then print("Through") d = playerschildren[v] print(d.Name) else print("Not") end end if pointsToAward > 0 then game:GetService("PointsService"):AwardPoints(d.userId, a) end end end) end)
In your loop, v
is a child from the list of players. As such it will be a Player instance. However, c
is a string. Since they have different types, the comparison on line 16 will always fail.
We need to compare v
's Name
with c
. It would also be more robust to do this case insensitive, so we should use something like:
if v.Name:lower() == c:lower() then