I wanted to make a script where when you put in a word you will get a word that ryhmes with it.
When I run the script nothing happens
this is the output:
Here is the script
-- Define the textbox and button
local TextBox = script.Parent.TextBox
local Button = script.Parent.Button
-- Define the function to find rhyming words
function FindRhymes(word)
-- Define the URL for the API
local url = "https://api.datamuse.com/words?rel_rhy="..word
-- Send a request to the API and get the response
local response = game:GetService("HttpService"):GetAsync(url, true)
local decoded = game:GetService("HttpService"):JSONDecode(response)
-- Loop through the response and add each word to the list
local rhymes = {}
for i, wordData in ipairs(decoded) do
table.insert(rhymes, wordData.word)
end
-- Return the list of rhyming words
return rhymes
end
-- Define the function to handle the button click event
Button.MouseButton1Click:Connect(function()
-- Get the player who clicked the button
local player = game.Players:GetPlayerFromCharacter(Button.Parent.Parent)
-- Get the word from the textbox
local word = TextBox.Text
-- Find the rhyming words
local rhymes = FindRhymes(word)
-- Send the list of rhyming words to the player
player:SendNotification(table.concat(rhymes, "\n"))
end)