Hello, I want to make it so on my portal, there is a sign that shows how many players are in a place. This means if a place has 5 players, then the sign would say 5 players. How do I do this?!?!?! I have some code here.
local sign = script.Parent
local HttpService = game:GetService("HttpService")
local QUERY_URL = "https://www.roblox.com/games/8036081158/Blaster-Battle"
local GAME_ID = game.GameId
-- "https://games.rprxy.xyz/v1/games?universeIds=000000"
local endpointResponse = HttpService:GetAsync(QUERY_URL .. GAME_ID)
local decodedResponse = HttpService:JSONDecode(endpointResponse)
local gameData = decodedResponse.data
local gameInformation = gameData[1]
local playersInGame = gameInformation.playing
print(playersInGame) -- 0
while true do
sign.Text = "Players:" + playersInGame
end
The variable “sign” is a TextLabel.
Error is Trust Check Failed.
Please help!!!
PLEASEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!
Its because roblox games cant access any roblox related sites. You have to use a site like roproxy.com. You just have to replace roblox.com with roproxy.com. Just do this.
local QUERY_URL = "https://www.roproxy.com/games/8036081158/Blaster-Battle"
Also, some errors with the code, keep in mind, this is written on mobile so there may be some issues
local sign = script.Parent
local HttpService = game:GetService("HttpService")
local QUERY_URL = "https://www.roproxy.com/games/8036081158/Blaster-Battle"
local GAME_ID = game.GameId
-- "https://games.rprxy.xyz/v1/games?universeIds=000000"
local endpointResponse = HttpService:GetAsync(QUERY_URL)
local decodedResponse = HttpService:JSONDecode(endpointResponse)
local gameData = decodedResponse.data
local gameInformation = gameData[1]
local playersInGame = gameInformation.playing
print(playersInGame) -- 0
while true do
sign.Text = "Players: " .. playersInGame
task.wait(1)
end
Nvm, just use this code, dont edit the query url this time, or it’ll break
local HttpService = game:GetService("HttpService")
local QUERY_URL = "https://games.roproxy.com/v1/games?universeIds="
local GAME_ID = game.GameId
-- "https://games.rprxy.xyz/v1/games?universeIds=000000"
local endpointResponse = HttpService:GetAsync(QUERY_URL .. GAME_ID)
local decodedResponse = HttpService:JSONDecode(endpointResponse)
local gameData = decodedResponse.data
local gameInformation = gameData[1]
local playersInGame = gameInformation.playing
print(playersInGame) -- 0
Dont edit anything, only add the while loop i updated for the text. NOTHING else
I gtg, gotta sleep. Thank you so much for your help! I will defininitely follow your advice. I have a stupid question. Do I put the entire thing into the while loop? Or do I put in the sign update thing into the while loop?
Just do this. Since the old code would get the old concurrent players
while true do
local HttpService = game:GetService("HttpService")
local QUERY_URL = "https://games.roproxy.com/v1/games?universeIds="
local GAME_ID = game.GameId
-- "https://games.rprxy.xyz/v1/games?universeIds=000000"
local endpointResponse = HttpService:GetAsync(QUERY_URL .. GAME_ID)
local decodedResponse = HttpService:JSONDecode(endpointResponse)
local gameData = decodedResponse.data
local gameInformation = gameData[1]
local playersInGame = gameInformation.playing
print(playersInGame) -- 0
task.wait(5)
end
local Http = game:GetService("HttpService")
while task.wait(5) do
local URL = "https://games.roproxy.com/v1/games?universeIds=3074028660"
local Data = Http:GetAsync(URL)
local DecodedData = Http:JSONDecode(Data)
local PlayingCount = DecodedData["data"][1]["playing"]
print(PlayingCount)
end
local Http = game:GetService("HttpService")
local bruh = script.Parent
while true do
local URL = "https://games.roproxy.com/v1/games?universeIds=3074028660"
local Data = Http:GetAsync(URL)
local DecodedData = Http:JSONDecode(Data)
local PlayingCount = DecodedData["data"][1]["playing"]
bruh.Text = "Players:" .. PlayingCount
wait(2)
end
and it instead showed me the amount of players in the whole EXPERIANCE. Blaster Battle is part of my game.
Huh? Should i put that into the link? Also, how do i use a place id instead of universe id? I want the amount of players ONLY in 1 place (all servers) @conra_virusman@Forummer
print("Stupid donkey.")
local Http = game:GetService("HttpService")
local bruh = script.Parent
while true do
local URL = "https://games.roproxy.com/v1/games?universeIds=8089169472"
local Data = Http:GetAsync(URL)
local DecodedData = Http:JSONDecode(Data)
local PlayingCount = DecodedData["data"][1]["playing"]
bruh.Text = "Players:" .. PlayingCount
wait(2)
end