-
What do you want to achieve? Keep it simple and clear!
I want to make a script that gets the likes of a game then puts the likes in a textlabel -
What is the issue? Include screenshots / videos if possible!
There is nothing helpful -
What solutions have you tried so far?
I have looked everywhere on the devforum and youtube but nothing helped.
you’ll need to use Roblox’s API to fetch the likes count from the game’s information. Here’s a simple script that demonstrates how you can do this:
luaCopy code
local gameId = -- Insert your game ID here
local textLabel = script.Parent:WaitForChild("LikesTextLabel")
local function updateLikes()
local success, gameInfo = pcall(game.MarketplaceService.GetProductInfo, game.MarketplaceService, gameId)
if success then
local likes = gameInfo.FavoritesCount
textLabel.Text = "Likes: " .. tostring(likes)
else
textLabel.Text = "Likes: N/A"
end
end
updateLikes()
Here’s how to use this script:
- Insert a TextLabel into your game UI.
- Replace
gameId
with the ID of your game (can be found in the URL of your game’s Roblox page). - Place the script in a location where it can access the TextLabel (e.g., as a child of the TextLabel’s parent).
This script uses the GetProductInfo
method from the MarketplaceService
to retrieve information about the game, including the number of favorites (likes). If the retrieval is successful, it updates the TextLabel’s text to display the likes count. If there’s an error (such as an incorrect game ID), it shows “Likes: N/A”.
Remember that this script relies on the API and requires your game to be published on Roblox. Additionally, be aware that Roblox’s API and services might change over time, so it’s a good practice to refer to Roblox’s official documentation for the most up-to-date information.
XD? nothing bro you read the question?
looks like he read the question quite well
Not to mention that it’s extremely obvious that they used ChatGPT to provide an answer to them.
oh wait now i see that it says ‘lua copy code’ lol
Still, i believe it would work anyways
I think you didn’t understand it, he wants to make a likes counter, and I put him if he read the question, because his code has nothing to do with it.
pretty sure thats what he asked for