-
What do you want to achieve?
I want the script to check and see if one player is friends with another. -
What is the issue?
It will not for some reason stay on the current player it is on. It will check a player against itself. -
What solutions have you tried so far?
I have tried almost everything I can think of. I don’t know why it isn’t working and I have tried looking to see if anyone has had similar issues.
In the screenshot below you can see what I mean by it just checks the player against itself.
local Plyrs = game.Players:GetChildren() -- Getting the main player to check and change stats of.
for i = 1, #Plyrs do -- Starting the loop
local friendswith = {} -- Table tosee what friends are in the game
table.clear(friendswith)
for i, v in pairs(game.Players:GetPlayers()) do -- This loop is to check the main player against every player in the server to see if they are playing with friends.
print(v.Name.." "..Plyrs[i].Name) -- This print statement tells me who it is checking the main player against
local ID = v.UserId
if Plyrs[i]:IsFriendsWith(ID) then -- Checks to see if the two players are friends.
table.insert(friendswith, v) -- Adds any friends to the table.
end
end
end
Sorry if the code is a bit messy. I have gone thru like 30 versions trying everything to get this to work. Also, the function is fired at the end of a round. Not when the game first starts obviously.