I’m trying to find a way to see if there is an error in the http request but I can’t
game.ReplicatedStorage.Events.JoinedEvent.OnServerEvent:Connect(function(Player,Lplayer)
local http = game:GetService('HttpService')
while true do
wait()
local response = http:RequestAsync({
Url = 'https://api.romanager.bot/v1/discord-roles/'..Lplayer.UserId,
Method = 'GET',
Headers = {
['Authorization'] = 'i-dont-show-my-api-key'
}
})
if response["Body"]["name"] then
script.Parent.Text = "You are in the server!"
else
script.Parent.Text = "you are not in the server!"
end
end
end)
The data is a JSONEncoded string not a dictionary. That’s why your code isn’t functioning as it should. If you decode the response before processing it the issue should be fixed(unless there are other issues as well, such as the response format being different or the API request being done incorrectly, etc):
--this function receives a JSON-encoded string and returns a dictionary
local data = http:JSONDecode(response)
if data["Body"]["name"] then
script.Parent.Text = "You are in the server!"
else
script.Parent.Text = "you are not in the server!"
end