RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"main menu gui with play and join friend button"
-- LocalScript inside the Play button local playButton = script.Parent local mainMenu = playButton.Parent local function onPlayButtonClicked() mainMenu.Visible = false -- Add any other actions you want to perform when the play button is clicked end playButton.MouseButton1Click:Connect(onPlayButtonClicked) -- LocalScript inside the Join Friend button local joinFriendButton = script.Parent local mainMenu = joinFriendButton.Parent local friendUsernameBox = mainMenu.FriendUsernameBox -- Assuming there's a TextBox named FriendUsernameBox in the main menu local function onJoinFriendButtonClicked() local friendUsername = friendUsernameBox.Text if friendUsername ~= "" then local success, message = pcall(function() game:GetService("TeleportService"):TeleportToPlaceInstance(game.PlaceId, game.Players:GetUserIdFromNameAsync(friendUsername)) end) if not success then warn("Failed to join friend: " .. message) end else warn("Please enter a friend's username") end end joinFriendButton.MouseButton1Click:Connect(onJoinFriendButtonClicked)