Fixing Follower Error

Hello developers, I was wondering if anyone can help me figure out why my script won’t work, the script should check if you are following me and if you are you get a reward but it doesn’t work. Any ideas?


type EndpointData = {
	nextPageCursor: string?,
	data: {
		[number]: {
			isDeleted: boolean,
			friendRequestScore: number,
			friendRequestRank: number,
			hasVerifiedBadge: boolean,
			description: string?,
			created: string?,
			isBanned: boolean,
			externalAppDisplayName: string?,
			id: number,
			name: string,
			displayName: string
		}
	}
}

type HttpRequestResponse = {
	Success: boolean,
	StatusCode: number,
	StatusMessage: string,
	Headers: { any },
	Body: any
}

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")
local HTTPService = game:GetService("HttpService")

local Profiles = require(ServerScriptService.Scripts.Data:FindFirstChild("Profile List"))

--: number

local TargetUserId = 3690340936  
Workspace:SetAttribute("FollowRequirement", TargetUserId)

local EndpointUrl = "https://friends.roproxy.com/v1/users/" .. TargetUserId .. "/followers"

function EndpointRequest(UserId: number, Cursor: string?): HttpRequestResponse?
	local Success: HttpRequestResponse? = nil

	while not Success do
		local PSuccess, PResult = pcall(function()
			return HTTPService:RequestAsync({
				Url = EndpointUrl .. "/followings?sortOrder=Desc&limit=100&cursor=" .. (Cursor or ""),
				Headers = {
					["Content-Type"] = "application/json",
					["job-id"] = game.JobId
				},
				Method = "GET"
			}) :: HttpRequestResponse | string
		end)

		if not PSuccess then
			if typeof(PResult) == "string" and PResult:match("Number of requests exceeded limit") then
				task.wait(10)
				continue
			end

			Success = nil
			break
		end

		Success = PResult :: HttpRequestResponse
	end

	return Success
end

function FetchFollow(UserId: number, Cursor: string?): EndpointData?
	local Result: HttpRequestResponse? = EndpointRequest(UserId, Cursor)

	if not Result then
		return
	end

	if not Result.Success or Result.StatusCode ~= 200 then
		return
	end

	local FollowData = HTTPService:JSONDecode(Result.Body) :: EndpointData
	return FollowData
end

function FetchUserFollowingStatus(UserId: number): boolean
	local NextCursor = nil

	repeat
		local Response: EndpointData? = FetchFollow(UserId, NextCursor)

		if not Response then
			break
		end

		for _, UserData in pairs(Response.data) do
			if UserData.id == TargetUserId then
				return true
			end
		end

		NextCursor = Response.nextPageCursor
	until NextCursor == nil

	return false
end

ReplicatedStorage.Remotes.FollowStatus.OnServerInvoke = function(Player: Player)
	local Status = FetchUserFollowingStatus(Player.UserId)

	if Status then
		Player:SetAttribute("GoldSpray", true) 
		if Profiles[Player.Name] then
			Profiles[Player.Name].Data.FollowerReward = true  
		end
		return true
	end

	return false
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

should be

				Url = EndpointUrl .. "?sortOrder=Desc&limit=100&cursor=" .. (Cursor or ""),
1 Like

I’d also suggest setting up a cloudflare worker instead of using roproxy.
That way if roproxy ever goes down or goes rogue it wouldn’t affect your code. But, just a suggestion it’ll probably be fine.

1 Like

Its still not working I also have another script is that maybe the problem?

local Workspace = game:GetService("Workspace")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LocalPlayer = Players.LocalPlayer

local UI = script:FindFirstChild("GoldPaintFollowerRewards"):Clone()

-- Automatically scale our UI, since we use offset for all of our UI
-- Mobile has 1.5x the amount of scale!
function UIScaleCheck()
	if (not UI) then
		return
	end

	local WinHeight = Workspace.CurrentCamera.ViewportSize.Y

	local Scale = math.min(WinHeight / 1080, 1)

	if (UserInputService:GetLastInputType() == Enum.UserInputType.Touch) then
		Scale *= 1.5
	end

	local UIScale = UI:FindFirstChild("UIScale") :: UIScale

	if (not UIScale) then
		return
	end

	UIScale.Scale = Scale
end

Workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
	UIScaleCheck()
end)
UIScaleCheck()

-- Status Check
local StatusButton = UI.Container.Status.Button

StatusButton.MouseButton1Click:Connect(function()
	local Result = ReplicatedStorage.Remotes.FollowStatus:InvokeServer()

	if (Result) then
		UI.Parent = nil
		StatusButton.Text = `Gold Unlocked! (1/1)`
	else
		StatusButton.Text = `Not Following! (0/1)`
	end
end)

-- Close Button
local CloseButton = UI.Container.Close.Button

CloseButton.MouseButton1Click:Connect(function()
	UI.Parent = nil
end)

-- Prompt Event
local PromptFollow = script.Parent.PromptFollow

PromptFollow.Event:Connect(function(UserId: number)
	local Name = Players:GetNameFromUserIdAsync(UserId)

	UI.Container.Body.Text = `Simply follow <b>"@{Name}"</b> on Roblox to unlock the gold paint!`
	UI.Container.PlayerIcon.Image = `rbxthumb://type=AvatarHeadShot&id={UserId}&w=150&h=150`

	UI.Parent = LocalPlayer:FindFirstChild("PlayerGui")
end)

That script would have no affect, are you certain you have HTTP requests enabled for your game?

Yes everything is enabled but for some reason it just dosent work. The script is supposed to check if that user is following me and if they are they get the gold spray color

This line ^ should be this:

if UserData.id == UserId then

It still docent work I really hate to keep bothering you this is the script with all your added changes!

type EndpointData = {
	nextPageCursor: string?,
	data: {
		[number]: {
			isDeleted: boolean,
			friendRequestScore: number,
			friendRequestRank: number,
			hasVerifiedBadge: boolean,
			description: string?,
			created: string?,
			isBanned: boolean,
			externalAppDisplayName: string?,
			id: number,
			name: string,
			displayName: string
		}
	}
}

type HttpRequestResponse = {
	Success: boolean,
	StatusCode: number,
	StatusMessage: string,
	Headers: { any },
	Body: any
}

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")
local HTTPService = game:GetService("HttpService")

local Profiles = require(ServerScriptService.Scripts.Data:FindFirstChild("Profile List"))

--: number

local TargetUserId = 3690340936  
Workspace:SetAttribute("FollowRequirement", TargetUserId)

local EndpointUrl = "https://friends.roproxy.com/v1/users/" .. TargetUserId .. "/followers"

function EndpointRequest(UserId: number, Cursor: string?): HttpRequestResponse?
	local Success: HttpRequestResponse? = nil

	while not Success do
		local PSuccess, PResult = pcall(function()
			return HTTPService:RequestAsync({
				Url = EndpointUrl .. "?sortOrder=Desc&limit=100&cursor=" .. (Cursor or ""),
				Headers = {
					["Content-Type"] = "application/json",
					["job-id"] = game.JobId
				},
				Method = "GET"
			}) :: HttpRequestResponse | string
		end)

		if not PSuccess then
			if typeof(PResult) == "string" and PResult:match("Number of requests exceeded limit") then
				task.wait(10)
				continue
			end

			Success = nil
			break
		end

		Success = PResult :: HttpRequestResponse
	end

	return Success
end

function FetchFollow(UserId: number, Cursor: string?): EndpointData?
	local Result: HttpRequestResponse? = EndpointRequest(UserId, Cursor)

	if not Result then
		return
	end

	if not Result.Success or Result.StatusCode ~= 200 then
		return
	end

	local FollowData = HTTPService:JSONDecode(Result.Body) :: EndpointData
	return FollowData
end

function FetchUserFollowingStatus(UserId: number): boolean
	local NextCursor = nil

	repeat
		local Response: EndpointData? = FetchFollow(UserId, NextCursor)

		if not Response then
			break
		end

		for _, UserData in pairs(Response.data) do
			if UserData.id == UserId then
				return true
			end
		end

		NextCursor = Response.nextPageCursor
	until NextCursor == nil

	return false
end

ReplicatedStorage.Remotes.FollowStatus.OnServerInvoke = function(Player: Player)
	local Status = FetchUserFollowingStatus(Player.UserId)

	if Status then
		Player:SetAttribute("GoldSpray", true) 
		if Profiles[Player.Name] then
			Profiles[Player.Name].Data.FollowerReward = true  
		end
		return true
	end

	return false
end
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HTTPService = game:GetService("HttpService")

local Profiles = require(ServerScriptService.Scripts.Data:FindFirstChild("Profile List"))

local TargetUserId = 3690340936
Workspace:SetAttribute("FollowRequirement", TargetUserId)

type EndpointData = {
	nextPageCursor: string?,
	data: {
		[number]: {
			id: number,
		}
	}
}

function GetFollowers(UserId: number, Cursor:string?)
	local HTTPResponse:EndpointData
	Cursor = Cursor or ""
	local function GetAsync()
		local success, err = pcall(function()
			HTTPResponse = HTTPService:GetAsync("https://friends.roproxy.com/v1/users/"..UserId.."/followers?sortOrder=Desc&limit=100&cursor="..Cursor)
		end)
		if not success then
			if err == "Number of requests exceeded limit" then
				task.wait(10)
				GetAsync()
			end
		end
	end
	GetAsync()
	HTTPResponse = HTTPService:JSONDecode(HTTPResponse)
	return HTTPResponse.data, HTTPResponse.nextPageCursor
end

function UserIsFollowing(TargetUserId:number, UserId:number)
	local Followers, NextPageCursor = {}, ""
	while NextPageCursor do
		Followers, NextPageCursor = GetFollowers(TargetUserId, NextPageCursor)
		
		for _, Follower in Followers do
			if Follower.id == UserId then
				return true
			end
		end
	end
	return false
end

ReplicatedStorage.Remotes.FollowStatus.OnServerInvoke = function(Player: Player)
	if UserIsFollowing(TargetUserId, Player.UserId) then
		Player:SetAttribute("GoldSpray", true) 
		if Profiles[Player.Name] then
			Profiles[Player.Name].Data.FollowerReward = true  
		end
		return true
	end

	return false
end

IT WORKS! Thank you so much I have been trying to fix this forever!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.