Any efficient way to do this?

  1. What do you want to achieve? Keep it simple and clear!
    I want for the game to tell the entire bee movie script one by one (and no the game won’t go public for some reasons)
  2. What is the issue? Include screenshots / videos if possible!
    The issue is that my method of doing it (which makes the script about +1500 lines) isn’t working right now.
    What method i am using is that i make a python script which generates +1500 lines in a text file that i need to make it work but the issue is that it’s doing a linebreak for every ') which ruins the script due to how syntax works but im not here for python problems im here to find an efficient way to do this and the script is like this
    Local Script:
local function AnimateText(interval,word)
	local AmountOfLettersToSubtract = 0
	while AmountOfLettersToSubtract < string.len(word) do
		wait(interval)
		script.Parent.Text = string.sub(word,1,string.len(word)-string.len(word)-string.len(word)+AmountOfLettersToSubtract)
		AmountOfLettersToSubtract += 1
	end
end
--Script continues with that text file i mentioned
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Can’t fine one
1 Like

I’m not sure I completely understand your problem, but have you tried getting the script using HttpService? Something like this will give you each line of the script.

pcall(function()
	local beeScript = game:GetService("HttpService"):GetAsync("https://gist.githubusercontent.com/The5heepDev/a15539b297a7862af4f12ce07fee6bb7/raw/7164813a9b8d0a3b2dcffd5b80005f1967887475/entire_bee_movie_script");
	local lines = beeScript:split(" - ");
	
	for i,v in ipairs(lines) do
		print(v);
	end
end)
2 Likes

Well i tried to use http service but i couldn’t find an hosted json file with the bee movie script in it and i never knew you can make an http request to request an text file
Ok so i tried your suggestion and it gives an error saying that i can’t send http request in a local script

just use [[ ]]

local text = [[hi
line breaks wont break this string
ok
cool
]]

I know but i want for the game to tell the bee movie script in a text label one by one not the entire script at once

send with a normal script. (not a localscript)

then just make a quick typewriter effect with string.sub
havent tested it yet

local speed = 0.01;
local text = [[
bee movie here
]];

local len = string.len(text);

for i = 1,len do
script.Parent.Text = string.sub(text,i,len);
wait(speed);
end;

I already have a typewriter effect function

Or you can copy and paste bee movie (link)

You mean a python script i made to write 1500 lines of scripts i need in a text file? Or just a script

Copy and paste into a variable

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 :honeybee:) 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.

What i meant by telling it one by one is that i meant for the game to tell one by one sentence or lines

1 Like

Also i don’t want to make it so if a button is clicked it fires that function

It’s easier if you explain what you do want than if you explain what you don’t want.

Also where is the script placed? Is it in the screenGui? TextLabel?

You can see how it’s structured if you download the place file, but it’s a LocalScript in the ScreenGui.

Ok i placed it in the screenGui and the Module Script is giving an error saying that http request can only be executed in game server and its placed in replicated storage

BeeMovieScript should be a modulescript that returns a string constant, NOT the one that gets stuff via HttpService.

1 Like

Agreed with what @ThanksRoBama said. If you have access to the entire script you can just import it into Roblox Studio as a module script returning a string. Then you would parse it into substrings separating by newline (‘\n’) characters.