I Tried to do my best explaining this. I want to make it so that UI has no text and then after 30 seconds the text change every 0.2 seconds, like this:
local text = game.workspace.starterGUI.screenGUI.Text1.Text
task.wait(30)
text = "bla bla bla"
task.wait(0.2)
text = "even more bla bla bla"
task.wait(0.2)
text = "whatever"
task.wait(0.2)
-- this just continues
When I tested this out it didn’t work. I looked at tutorials and on here but I didn’t find an answer. I tried moving the script to different places and changing it by doing minor adjustments but it still wouldn’t work.
The tutorial I found showed me how to do it but it didn’t work when I tested it. I looked here for answers and it was hard to find any.
The script I used isn’t finished yet because I was smart and decided to test the script before going too far and it didn’t work so I’m glad I did that. This is the script I actually used:
local text = script.Parent.Text
local audio1 = game.Workspace.TypeWriter1
local audio2 = game.Workspace.TypeWriter2
task.wait(30)
text = "I"
audio1:Play()
task.wait(0.2)
text = "It"
audio2:Play()
task.wait(0.2)
text = "It a"
audio1:Play()
task.wait(0.2)
text = "It al"
audio2:Play()
task.wait(0.2)
text = "It all"
audio1:Play()
task.wait(0.2)
text = "It all s"
audio2:Play()
task.wait(0.2)
text = "It all st"
audio1:Play()
task.wait(0.2)
text = "It all sta"
audio2:Play()
task.wait(0.2)
text = "It all star"
audio1:Play()
task.wait(0.2)
text = "It all start"
audio2:Play()
task.wait(0.2)
Why does everything I have to do in Roblox studio be confusing to me?..
Here’s the problem, you need to understand something special about all programming languages, it’s called value type vs reference type. Instead of creating a new variable that is the PROPERTY Text create a variable that is the GuiObject you’re trying to change.
local text = script.Parent
text.Text = "YAY IT WORKS!"
The variable you’re creating is holding the VALUE of the text of the object, not a reference to it. So if you try to assign it a value, you’re just going to end up with a variable with a string. Instead create a variable that is a reference to the object, and change it’s text accordingly.
Also, are you sure you’re using the most efficient way to do your script? I see you’re trying to achieve a typewriter effect, but this could be way easily done with loops.
Quite a few issues with your code. Where is your ‘TextLabel’ located? Is it the parent of the script? Because if it is, this is not the correct way of getting the TextLabel.
Also, instead of making unnecessary code blocks, you could instead use a for loop to change the text.
Your fixed code:
local TextLabel = script.Parent
local audio1 = game.Workspace.TypeWriter1
local audio2 = game.Workspace.TypeWriter2
local message = "It all start" -- put your full message here
task.wait(30)
for i = 1, #message, 1 do
TextLabel.Text = string.sub(message, 1, i)
task.wait(0.2)
end
I tried this and it still didn’t work, however thanks for the tips so I can use them for the future. I am trying to make a typewriter effect and my next plan is to make the pitch of the sound vary (which I’m not sure how to do yet). The only way I know how to change the pitch is to change the speed but I should be able to figure it out I hope. Also I had duplicate the sound because by the time new text appeared the sound wouldn’t be over so it caused issues (duration 0.217 seconds).
I don’t entirely understand how this works but it does. You and @Den_vers saved me some trouble by reminding me of loops. My TextLabel is located here btw: