- What do you want to achieve? Keep it simple and clear!
I want to make a game where you can Join other Players.
- What is the issue? Include screenshots/videos if possible!
When I execute the /v1/presence/users API, I get this:
But when I make a POST request in-game, I get this:
Many things are now missing from the table! Anyone know why?
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched on the DevForum, Internet, etc…
This is the code I’m using if anybody needs it:
-- Services
local HTTP = game:GetService("HttpService")
local ReplicatedS = game:GetService("ReplicatedStorage")
-- Variables
local URL = "https://presence.roproxy.com/v1/presence/users"
local Remote = ReplicatedS:FindFirstChild("Player")
-- Function
local function getPresenceData(plr : Player, userID : number)
local data = HTTP:JSONEncode({
["userIds"] = {userID}
})
local succ, response = pcall(function()
return HTTP:PostAsync(URL, data)
end)
if succ then
response = HTTP:JSONDecode(response)
print(response)
Remote:FireClient(plr, response)
else
warn("There was an error while accessing presence.roblox.com : " .. response)
end
end
Remote.OnServerEvent:Connect(getPresenceData)
And this is the client Script:
-- Services
local UserService = game:GetService("UserService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Variables
local GUI = script.Parent
local Backgrond = GUI:WaitForChild("Background")
local MainFrame = Backgrond:WaitForChild("Main")
local UsernameInput = MainFrame:WaitForChild("Username")
local Username = MainFrame:WaitForChild("UsernameLabel")
local DisplayName = MainFrame:WaitForChild("Displayname")
local UserIcon = MainFrame:WaitForChild("UserIcon")
local placeID = MainFrame:WaitForChild("Place-ID")
local JobID = MainFrame:WaitForChild("Job-ID")
local LastOnline = MainFrame:WaitForChild("LastOnline")
local Remote = ReplicatedStorage:WaitForChild("Player")
-- Functions
local function Input(text : string)
local data = Players:GetUserIdFromNameAsync(text)
Remote:FireServer(data)
end
--local function calculateLastOnline(lastOnlineString)
-- local year, month, day, hour, min, sec = lastOnlineString:match("(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+.%d+)Z")
-- if year and month and day and hour and min then
-- return string.format("%02d:%02d:%02d:%02d:%02d", tonumber(min), tonumber(hour), tonumber(day), tonumber(month), tonumber(year))
-- else
-- return "Invalid last online format"
-- end
--end
local function Setup(response)
if response.userPresences and #response.userPresences > 0 then
local userPresence = response.userPresences[1]
print(userPresence)
local userId = userPresence.userId
local dn = UserService:GetUserInfosByUserIdsAsync({userId})
local Un = Players:GetNameFromUserIdAsync(userId)
local icon = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
DisplayName.Text = dn[1].DisplayName
Username.Text = "@" .. Un
UserIcon.Image = icon
placeID.Text = "Place ID: " .. "Not In-Game!" or userPresence.placeId
JobID.Text = "Job ID: " .. "Not In-Game!" or userPresence.gameId
--LastOnline.Text = "Last Online: " .. calculateLastOnline(userPresence.lastOnline)
else
warn("No user presences found in the response.")
end
end
UsernameInput.FocusLost:Connect(function(enter)
if enter then
Input(UsernameInput.Text)
end
end)
Remote.OnClientEvent:Connect(Setup)
Any help would be much appreciated