How can I make a tool that friends random players in the server?

This game sorta popped up from the middle of nowhere and I don’t know where it came from but it’s pretty interesting.

In it, there’s a tool that repeatedly prompts you to add other players in the server when you equip it, and if you cancel/friend that person another prompt pops up if you have the tool equipped.

I know there are methods to add players, but how can it tell if you added/declined a prompt? I don’t think it’s just a loop either, it seems like it’s very on-timing after you close one and there’s no noticeable lag. How would I create something similar to this? (I don’t really understand how the friending API thing works)

Also how would you make a tool that spam prompts you to buy certain items, and if you already have them prompts you to change to a certain avatar? The game is certainly interesting and it would be funny to make my own game like it, albeit more of a troll game than a raiding game.

1 Like

I would look into the :SetCore() method using the "PromptSendFriendRequest" callback, and fire it when the Tool is equipped.

For a random player selection, I would use the math.random() function from the math library.

local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")

function sendFQ(player: Player)
    local randomPlayer = nil -- use something with math.random() here
    StarterGui:SetCore("PromptSendFriendRequest", randomPlayer)
end
2 Likes

Well yeah, im kinda dumb and named the system I wanted to make instead of the parts I generally know. Upon checking out the announcement I found StarterGui:GetCore("PlayerFriendedEvent"), does this tell you when that prompt box closes? I was wondering how the game knew the prompt was closed.

The "PlayerFriendedEvent" callback will return a BindableEvent.

Accepting or rejecting a friend request will close the prompt inevitably, so yes, it will fire once someone interacts with the prompt, which closes it.

Since it returns a BindableEvent, you can simply use the .Event signal:

local StarterGui = game:GetService("StarterGui")
local friendEvent = StarterGui:GetCore("PlayerFriendedEvent")

friendEvent.Event:Connect(function(player: Player)
    print("The player friended you! This prompt has closed.")
end)

If you want to detect a player unfriending another player, then use the PlayerUnfriendedEvent callback, but I assume you’ve seen that already.

Hope this helps.

1 Like

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