Here’s how you can make a ModuleScript return the Bee Movie script as a string:
local Http = game:GetService("HttpService")
local text_url = [[https://gist.githubusercontent.com/The5heepDev/a15539b297a7862af4f12ce07fee6bb7/raw/7164813a9b8d0a3b2dcffd5b80005f1967887475/entire_bee_movie_script]]
local text = Http:GetAsync(text_url)
return text
Or download it here:
BeeMovieScript.rbxmx (52.8 KB)
It’s not clear what you mean by “telling it one by one”. One word? One sentence? Either way, I prefer using an iterator to iterate over the parts of the text instead of extracting them all at once and storing them in a table. This way, we don’t have to store all of the text yet another time in the client’s RAM (although it’s only ~50kb so it’s actually no biggie), and there’s no up-front processing that has to happen when a player joins (although again, it’s only like 50k characters, so might not even be noticable). If you just want to go forwards in the text we can use string.gmatch
. You can match sentences like this:
local sentence_delimiters = "[.!?]"
local sentence_pattern = "..-" .. sentence_delimiters --any 1 char, then any or 0 chars, as few as possible, then any 1 sentence delimiter
function sentence_forwards_iter(text)
return string.gmatch(text, sentence_pattern)
end
I’ve made an example GUI with a TextLabel. To show the next sentence, call this function:
function show_next_sentence()
textLabel.Text = text_sentence_iter()
end
Here's the entire GUI script:
function WaitForDescendant(ancestor, descendant_name)
assert(typeof(ancestor) == "Instance")
assert(typeof(descendant_name) == "string")
local descendant = ancestor:FindFirstChild(descendant_name, true)
while (not descendant) do
local addedDescendant = ancestor.DescendantAdded:Wait()
if addedDescendant.Name == descendant_name then
descendant = addedDescendant
end
end
return descendant
end
local screen = script.Parent
local textLabel = WaitForDescendant(screen, "TextLabel")
local forwButton = WaitForDescendant(screen, "ForwButton")
local text = require(game.ReplicatedStorage.BeeMovieScript)
local sentence_delimiters = "[.!?]"
local sentence_pattern = "..-" .. sentence_delimiters .. "+" --any 1 char, then any or 0 chars, as few as possible, then 1 or more sentence delimiters, as many as possible
function sentence_forwards_iter(text)
return string.gmatch(text, sentence_pattern)
end
local text_sentence_iter = sentence_forwards_iter(text)
function progress_slides()
textLabel.Text = text_sentence_iter()
end
progress_slides() --show first sentence
forwButton.MouseButton1Down:Connect(progress_slides)
And here you can download the place file with the Gui and everything. Fetching the script from github only works in an uploaded place with HttpService enabled, but it’s not necessary because a local version of the text is saved in a ModuleScript.
EDIT: There was a bug (lol
) in the sentence_pattern. It didn’t match “sentence…”, instead matching “sentence.”, “.”, “.”. It’s fixed in this post but not in the files I uploaded.