Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Follow a Friend GUI?

Asked by 7 years ago
Edited 7 years ago

So i need help making a follow a friend GUI for my popular game Delitive Mod, I have this chunk of code provided by TheLowOne, but I am unsure how to transcript it to make it GUI compatible. Here's the code:

--The whole script has not been tested, change it your likings
function GetFriends(player) --I do not feel like upvaluing it
    return player:GetFriendsOnline(200) --max is 200
end
function GetFriendsInGame(friends)
    local new_friends = {} --dont mean it like thatl
    local placeid = game.PlaceId
    local temp
    for x = 1, #friends do
        temp = friends[x]
        if (temp.IsOnline) then
            if (temp.PlaceId == placeid) then
                new_friends[#new_friends + 1] = temp
            end
        end
    end
    return new_friends
end
--you could make a gui that selects a friend, and maybe hit follow friendinto game
--if you do you then do
function FollowFriend(player, userId)
    --player == main player, userId == the player to follow
    --(if this was for the gui, and the player hit the follow button for the player, you would provide the VisitorId from the online friends table)
    local tp = game:GetService("TeleportService")
    local success, emsg, placeId, instanceId = tp:GetPlayerPlaceInstanceAync(userId)
    if (success) then
        tp:TeleportToPlaceInstance(placeId, instanceId, player)
    else
        script.Parent.JoinAFriend.Text = "Offline"
    end
end    
script.Parent.SearchButton.MouseButton1Down:connect(FollowFriend)

`

I started to configure it a little bit but it was a null attempt, someone please help! Thanks! Also, credit will be given.

0
commenting for later Prioxis 673 — 7y
0
Helpful.... Connor_1 3 — 7y
2
line 025: should be tp:GetPlayerPlaceInstanceAsync(userId). Perhaps, try that. Sxerks3 65 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

This assumes that the script is the child of a TextButton

Edit: Fixed line 32

You would just have to supply the current player and the user id of the player to follow on line 32

--The whole script has not been tested, change it your likings
function GetFriends(player) --I do not feel like upvaluing it
    return player:GetFriendsOnline(200) --max is 200
end
function GetFriendsInGame(friends)
    local new_friends = {} --dont mean it like thatl
    local placeid = game.PlaceId
    local temp
    for x = 1, #friends do
        temp = friends[x]
        if (temp.IsOnline) then
            if (temp.PlaceId == placeid) then
                new_friends[#new_friends + 1] = temp
            end
        end
    end
    return new_friends
end
--you could make a gui that selects a friend, and maybe hit follow friendinto game
--if you do you then do
function FollowFriend(player, userId)
    --player == main player, userId == the player to follow
    --(if this was for the gui, and the player hit the follow button for the player, you would provide the VisitorId from the online friends table)
    local tp = game:GetService("TeleportService")
    local success, emsg, placeId, instanceId = tp:GetPlayerPlaceInstanceAsync(userId)
    if (success) then
        tp:TeleportToPlaceInstance(placeId, instanceId, player)
    else
        script.Parent.JoinAFriend.Text = "Offline"
    end
end    
script.Parent.MouseButton1Click:connect(FollowFriend(player, userId))
0
This wasn't tested shadownetwork 233 — 7y
0
uh this answer was given 6 months after the question was asked. phxtn 154 — 6y
Ad

Answer this question