Facebook
From part 3, 2 Months ago, written in Plain Text.
This paste is a reply to Re: Re: Re: Re: Re: skibideez from skibidiz ohio limited - view diff
Embed
Download Paste or View Raw
Hits: 153
  1. local gyro = GetPartFromPort(1, "Gyro")
  2.  
  3. -- Gets the player's info
  4. local function getPlayerInfo(playerName)
  5.     -- TODO: replace this with a real function that fetches the player's info from the Roblox leaderboard API
  6. end
  7.  
  8. -- Set up motor pins
  9. local motorPins = {12, 13, 14} -- {1:Left Motor, 2:Right Motor, 3:Vertical Motor}
  10. -- Set up speed for motors
  11. local speed = 50 -- speed value between 0 and 100
  12.  
  13. -- Target player to follow
  14. local targetPlayer = nil
  15.  
  16. -- Function to start targeting a player
  17. function target(playerName)
  18.     targetPlayer = playerName
  19.     print("Now following " .. targetPlayer .. " in leaderboard roblox list.")
  20. end
  21.  
  22. -- Function to stop targeting a player
  23. function stopTargeting()
  24.     targetPlayer = nil
  25.     print("Stopped targetting the player in leaderboard roblox list.")
  26. end
  27.  
  28. -- Set up the microphone
  29. local microphone = GetMicrophoneFromPort(2)
  30.  
  31. -- Function to process microphone commands
  32. function processMicrophoneCommand(command)
  33.     local detectedPlayerName = string.match(command, "target (.+) with a code block")
  34.     if detectedPlayerName then
  35.         target(detectedPlayerName)
  36.     end
  37. end
  38.  
  39. -- Main loop
  40. while true do
  41.     if targetPlayer then
  42.         local playerInfo = getPlayerInfo(targetPlayer)
  43.         if playerInfo then
  44.             local targetAngle = math.atan2(playerInfo.Y - 50, playerInfo.X - 50) * 180 / math.pi
  45.             gyro.targetRotationY(targetAngle)
  46.         else
  47.             print("Player not found in leaderboard roblox list.")
  48.         end
  49.     end
  50.    
  51.     -- Check if the microphone is activated
  52.     if microphone.isActivated() then
  53.         -- Get the command from the microphone
  54.         local command = microphone.getCommand()
  55.        
  56.         -- Process the command
  57.         processMicrophoneCommand(command)
  58.     end
  59.    
  60.     wait(0.05)
  61. end
  62.  
  63. -- Connect the "Chatted" event to the microphone
  64. microphone.on("Chatted", function(player)
  65.     local command = player.Character.Head.SurfaceGui.TextBox.Text
  66.     processMicrophoneCommand(command)
  67. end)