Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I generate a random word?

Asked by 5 years ago
Edited 5 years ago

How can I generate a random word? I was thinking of doing a 'post request' from http://watchout4snakes.com/wo4snakes/Random/RandomWord but im not sure how to.

0
i never knew you can use that for random generation cool actually starmaq 1290 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

nvm, This works:

local HttpService = game:GetService("HttpService")

local function randomword()

local response = HttpService:RequestAsync(

{

Url = "http://watchout4snakes.com/wo4snakes/Random/RandomWord", -- This website helps debug HTTP requests

Method = "POST",

Headers = {

["Content-Type"] = "application/json"

},

Body = HttpService:JSONEncode({hello = "world"})

}

)

-- Inspect the response table

if response.Success then

return(response.Body)

else

print("The request failed:", response.StatusCode, response.StatusMessage)

end

end

local success, message = pcall(randomword)

if not success then

print("Http Request failed:", message)

end




print(randomword())
Ad

Answer this question