Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I convert a string into a table?

Asked by 5 years ago
game.Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:connect(function(msg)
        local msgs = string.gmatch(msg,"%S+")
        for i,v in pairs(msgs) do
            print(v)
        end
    end)
end)

When I do this, I get an error that msgs is a function.

0
Just simply remove `pairs`. ;3 TheeDeathCaster 2368 — 5y
0
Well, that and remove the 'i' also. EmilyBendsSpace 1025 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
game:GetService("Players").PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        local msgs = string.gmatch(msg,"%S+")
        for v in msgs do
            print(v)
        end
    end)
end)

Edited so that I don't get comments about the deprecated lowercase connect or accessing PlayerService by name.

Ad

Answer this question