Game Like Counter

Hello, how to make the TextLabel display the number of likes in the game and update accordingly for 30 seconds?

1 Like

you have to use HttpService and a proxy to send a request to roblox apis to get the likes just like in a similar post https://devforum.roblox.com/t/how-do-i-get-the-amount-of-likes-my-game-has/1257746

1 Like

This tutorial not only explains everything but gives you a free model as well.

1 Like

how fix error - “Http requests can only be executed by game server

2 Likes

Hello :wave:,

you can not make HTTP requests from the client, you need a server script to do this :grimacing:.

Hope this helps!

1 Like

Don’t use a local script.

char limit.

1 Like

thanks it helped but now the error is “Can’t Parse Json

Script:

local HttpService = game:GetService("HttpService") -- HTTPS Service (VERY importnant)
local UniverseId = 4722660579  -- Game UniverseId you can get it from https://api.roblox.com/universes/get-universe-containing-place?placeid=PLACE_ID_HERE (VERY importnant)

local formatNumber = (function (n) n = tostring(n) return n:reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "") end) -- number formatting (importnant) 

repeat wait(1) -- refresh time, you can change from 1 to anything (minimum is 1 or lower will bug formatred numbers)

	local response = HttpService:RequestAsync({ -- gets live like count (VERY importnant)
		Url = "https://games.roproxy.com/v1/games/votes?universeIds="..UniverseId, -- gets live like count (VERY importnant)
		Method = "GET" -- gets live like count (VERY importnant)
	}) -- gets live like count (VERY importnant)

	local votes = HttpService:JSONDecode(response.Body) -- gets live like count (VERY importnant)
	script.Parent.Likes.Text = "Live Likes: "..formatNumber(votes.data[1].upVotes) -- setting text in game.Workspace.CPart.SurfaceGui.TextLabel to live likes
	script.Parent.Refresh.Text = "Refreshing..." -- setting text in game.Workspace.CPart.SurfaceGui.reTextLabel to live Refreshing...
until	-- nil (VERY importnant)
nil -- nil (VERY importnant)
1 Like

thanks it helped but now the error is “Can’t Parse Json

Script:

local HttpService = game:GetService("HttpService") -- HTTPS Service (VERY importnant)
local UniverseId = 4722660579  -- Game UniverseId you can get it from https://api.roblox.com/universes/get-universe-containing-place?placeid=PLACE_ID_HERE (VERY importnant)

local formatNumber = (function (n) n = tostring(n) return n:reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "") end) -- number formatting (importnant) 

repeat wait(1) -- refresh time, you can change from 1 to anything (minimum is 1 or lower will bug formatred numbers)

	local response = HttpService:RequestAsync({ -- gets live like count (VERY importnant)
		Url = "https://games.roproxy.com/v1/games/votes?universeIds="..UniverseId, -- gets live like count (VERY importnant)
		Method = "GET" -- gets live like count (VERY importnant)
	}) -- gets live like count (VERY importnant)

	local votes = HttpService:JSONDecode(response.Body) -- gets live like count (VERY importnant)
	script.Parent.Likes.Text = "Live Likes: "..formatNumber(votes.data[1].upVotes) -- setting text in game.Workspace.CPart.SurfaceGui.TextLabel to live likes
	script.Parent.Refresh.Text = "Refreshing..." -- setting text in game.Workspace.CPart.SurfaceGui.reTextLabel to live Refreshing...
until	-- nil (VERY importnant)
nil -- nil (VERY importnant)
1 Like

Can you give me the error you get in the console?

1 Like

Can’t parse JSON - Server - Script:13
Stack Begin - Studio
Script ‘Players.F0ZYAN.PlayerGui.AdminPanel.Script’, Line 13 - Studio - Script:13
Stack End - Studio

1 Like

Before the line local votes = HttpService:JSONDecode(response.Body) try putting print(response) and give me the output.