Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = game.Players.LocalPlayer
- local TextChatService = game:GetService("TextChatService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local isLegacyChat = TextChatService.ChatVersion == Enum.ChatVersion.LegacyChatService
- function chatMessage(str)
- str = tostring(str)
- if not isLegacyChat then
- TextChatService.TextChannels.RBXGeneral:SendAsync(str)
- else
- ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(str, "All")
- end
- end
- -- Define the URL for cat facts
- local url = "https://meowfacts.herokuapp.com/"
- -- Create an HTTP service instance
- local HttpService = game:GetService("HttpService")
- -- Define the character limit for TextChat
- local textChatCharacterLimit = 200
- -- Function to fetch the cat fact
- local function fetchCatFact()
- local validFact = false
- local catFact = ""
- while not validFact do
- -- Make the GET request
- local response = game:HttpGet(url)
- if response then
- -- Decode the JSON response
- local responseData = HttpService:JSONDecode(response)
- -- Extract the third line of content (assuming it's a string list)
- catFact = responseData.data[3] -- Adjust the index based on actual response structure
- -- Check if the cat fact is within the character limit
- if #catFact <= textChatCharacterLimit then
- validFact = true
- end
- else
- warn("Failed to fetch valid cat fact")
- return
- end
- end
- -- Output the valid cat fact
- chatMessage(catFact)
- end
- -- Fetch the cat fact
- fetchCatFact()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement