--I've tried but this won't work. game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if msg:sub(1,2) == "h/" then -My chatted command game:GetService("HttpService"):GetAsync(msg:sub(3))-Gets any raw link when saying h/. end end) end) --What I want it to do is that whenever I type "h/" it sends the link back using the function getasync. And that means any link. That has roblox lua code in it.
Try this:
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if msg:sub(0,2):match("h/") then game:GetService("HttpService"):GetAsync(msg:sub(3)) end end) end)
The issue was you were selecting only 1,2 of the message to select h/. I also changed it so that it uses a more reliable function called :match()
, which matches any part of a string.
The string, or any string, when using :sub
, starts at 0, then ends at the total length of the string.