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

Why can't I get the friends using HttpService?

Asked by
Prioxis 673 Moderation Voter
9 years ago

So I recently read the blog post about how to show user REP from SH in a roblox game I tried that and it worked!

But now doing something using roblox trying to relay the amount of friends a user has into the game isn't working out so well

I basically just rewrote some of the variables from the original script and changed some stuff around including the profile linking with the roproxy.tk so I can get information from a roblox website because you can't do that with roblox.com

Anyway here's the script

local nom = 3319957
local link  = "http://www.roproxy.tk/users/" .. nom .. "/profile"

local Service = game:GetService("HttpService")
local html = Service:GetAsync(link, false)


local string = [[<div>%d+Friends</div>]]
local snippet = html:match(string)
Reputation = (snippet:match("%d+"))


function getRep(Player)
    local nom = Player -- Create a string variable of the name
    local link  = "http://www.roproxy.tk/users/" .. nom .. "/profile" 
    local Service = game:GetService("HttpService")
    local html = Service:GetAsync(link, false)
    local string = [[<div>%d+Friends</div>]]
    local snippet = html:match(string)
    Reputation = (snippet:match("%d+"))

    return ("Player has " .. Reputation .. " Friends on Roblox.com")
end

Here's the output error I'm getting

https://i.gyazo.com/ef4104412b80e79febdc2ce21fac5d17.png

1 answer

Log in to vote
1
Answered by 9 years ago

The problem is simple. Your pattern won't match the page.

Try this pattern instead: html:match('href="http://www.roblox.com/users/'..nom..'/friends#!/friends">(d+)</a>')

0
e.e still more issues but thank you this did help a bit Prioxis 673 — 9y
0
What issues are you having now? TickerOfTime 70 — 9y
Ad

Answer this question