You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to use roproxy’s API to return places currently playing
- What is the issue? Include screenshots / videos if possible!
The issue is that I dont understand apis and my first time ever using it, The error is attempt to concatenate string with nil
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Most posts with solutions to “attempt to concatenate string with nil” are not related to API stuff which won’t help me in my current situation
local mapselection = script.Parent
local mapdetails = script.Parent.Parent.MapInfo
local description = mapdetails.Description
local name = mapdetails.Creator
local Image = mapdetails.MapImage
local playercount = mapdetails.PlayerCount
local play = mapdetails.PlayButton
local mainframe = script.Parent.Parent
local mapid = mainframe.MapID
local mapname = mapdetails.MapName
local teleportservice = game:GetService("TeleportService")
local message = game:GetService("MessagingService")
local http = game:GetService("HttpService")
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
for _,button in pairs(mapselection.ScrollingFrame:GetChildren()) do
if button:IsA("ImageButton") then
button.MouseButton1Click:Connect(function()
if game:GetService("ReplicatedStorage").MapInfo:FindFirstChild(button.Name) ~= nil then
local text = require(game:GetService("ReplicatedStorage").MapInfo:FindFirstChild(button.Name))
local playing = nil
local success,result = pcall(function()
playing = http:JSONDecode(http:GetAsync("https://games.roproxy.com/v1/games?universeIds="..tostring(text.playingid)))
end)
description.Text = text.Description
name.Text = text.Name
Image.Image = text.Image
mapname.Text = button.Name
mapid.Value = text.Id
if success then
playercount.Text = "Players currently playing: "..playing.data.playing -- error here, error is 'attempt to concatenate string with nil'
else
playercount.Text = "Error loading players."
print(result)
end
mapdetails.Visible = true
end
end)
end
end
play.MouseButton1Click:Connect(function()
teleportservice:Teleport(mapid.Value,plr)
end)