Hello, i have a join a friend script and im trying to make it where The gui to join them only appears if there playing a certain game so a certain GameId, rn its for every game.
local Player = game.Players.LocalPlayer
local Friends = Player:GetFriendsOnline(10)
local Temp = game.ReplicatedStorage.Template
local TPS = game:GetService("TeleportService")
for i,v in pairs(Friends) do
local NewFrame = Temp:Clone()
NewFrame.PlayerName.Text = v.UserName
NewFrame.Parent = script.Parent.ScreenGui.Frame.ScrollingFrame
NewFrame.PlayerImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username="..v.UserName
if v.LastLocation then
NewFrame.GameName.Text = v.LastLocation
NewFrame.Join.MouseButton1Down:Connect(function()
TPS:TeleportToPlaceInstance(v.PlaceId, v.UserName, Player)
end)
end
end
Right now it gives you the option to join anybody who’s playing a roblox game and any game, im trying to make it where the frame to join only gets cloned if there playing a certain game which is my game
So basically a join a friends lobby but this one is to join any lobby so I need to make it where it only clones for certain games your friend is playing
local UniverseId = game.GameId --universe id of current place
if v.LastLocation and v.GameId == UniverseId then
--code here only applies for places which belong in this game
end
You don’t need to. Simply keep it as it is and run it:
local Player = game.Players.LocalPlayer
local Friends = Player:GetFriendsOnline(10)
local Temp = game.ReplicatedStorage.Template
local TPS = game:GetService("TeleportService")
for i,v in pairs(Friends) do
if v.GameId ~= game.GameId then continue end --skip current frame
local NewFrame = Temp:Clone()
NewFrame.PlayerName.Text = v.UserName
NewFrame.Parent = script.Parent.ScreenGui.Frame.ScrollingFrame
NewFrame.PlayerImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username="..v.UserName
if v.LastLocation then
NewFrame.GameName.Text = v.LastLocation
NewFrame.Join.MouseButton1Down:Connect(function()
TPS:TeleportToPlaceInstance(v.PlaceId, v.UserName, Player)
end)
end
end
This is kinda what I want, even if there not playing my game the template gui is still gonna get cloned and show them playing a game I want it only to clone if it’s my game
local Player = game.Players.LocalPlayer
local Friends = Player:GetFriendsOnline(10)
local Temp = game.ReplicatedStorage.Template
local TPS = game:GetService("TeleportService")
for i,v in pairs(Friends) do
if v.GameId == 6803595647 then
local NewFrame = Temp:Clone()
NewFrame.PlayerName.Text = v.UserName
NewFrame.Parent = script.Parent.ScreenGui.Frame.ScrollingFrame
NewFrame.PlayerImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username="..v.UserName
if v.LastLocation then
NewFrame.GameName.Text = v.LastLocation
NewFrame.Join.MouseButton1Down:Connect(function()
TPS:TeleportToPlaceInstance(v.PlaceId, v.UserName, Player)
end)
end
end
end
Of course it didn’t because you have to copy exactly what I posted above, if you keep applying changes it wont work(if I didn’t make it clear the first 5 times I told you).
I changed the script and now it should work as you want it. All you have to do is change the Id to the type of game you want the player to teleport to.
Here’s the script:
local Player = game.Players.LocalPlayer
local Friends = Player:GetFriendsOnline(10)
local Temp = game.ReplicatedStorage.Template
local TPS = game:GetService("TeleportService")
local currentPosition = UDim2.new(0.06,0,0,25) -- You can adjust the position
for i,v in pairs(Friends) do
if v.PlaceId == [GAME ID} then
local userId = v.VisitorId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
local NewFrame = Temp:Clone()
NewFrame.PlayerName.Text = v.UserName
NewFrame.Parent = script.Parent.Parent.Parent.JoinFriendFrame
NewFrame.PlayerImage.Image = content --"http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username="..v.UserName
NewFrame.Position = currentPosition
local GetName = game:GetService("MarketplaceService"):GetProductInfo(v.PlaceId)
if v.LastLocation then
NewFrame.GameName.Text = GetName.Name
NewFrame.Join.MouseButton1Down:Connect(function()
TPS:TeleportToPlaceInstance(v.PlaceId, v.GameId, Player)
end)
end
currentPosition = currentPosition + UDim2.new(0,0,0,150)
end
end