Hi guys I am trying to get moving text to show after a screen is not visible or if the text is now visible. I tried if statements and a while loop but it seems those don’t work.
(don’t mind the textservice and input service that is something else.)
local TextService = game:GetService("TextService")
local UserinputService = game:GetService("UserInputService")
local create = script.Parent.Parent.Frame
local Name = script.Parent.NameLabel.Nametext
local text = "What is your name?"
for i = 1, #text do
script.Parent.NameLabel.Text = string.sub(text,1,i)
local cor = coroutine.wrap(function()
local sound = Instance.new("Sound")
sound.Volume = .5
sound.SoundId = "rbxassetid://3682239219"
sound.Parent = script.Parent.Parent
sound:Play()
sound.Ended:wait()
sound:Destroy()
end)
cor()
wait()
end
local function onFocusLost(enterPressed)
if enterPressed then
Name.Visible = false
end
end
Name.FocusLost:Connect(onFocusLost)
A video for more clarification:
I want the text and the text sounds to appear after the first screen disappears
I think her issues is the code is running at the same time as the roblox loading screen, so the text “typing” feature isn’t displaying.
Don’t know if it’d help, but you might try just removing the default loading screen with
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)
local GUI = script.StartScreen:Clone()
GUI.Parent = PlayerGui
here is the Create Spirit screen code:
-- Screens
local create = script.Parent.Frame.Create
local choice = script.Parent.ChoiceFrame
--fade variables
local frame = script.Parent.Frame
local Ptext = script.Parent.Frame.Ptext
local Rtext = script.Parent.Frame.Rtext
local Otext = script.Parent.Frame.Otext
local Jtext = script.Parent.Frame.Jtext
local Etext = script.Parent.Frame.Etext
local Ctext = script.Parent.Frame.Ctext
local Ttext = script.Parent.Frame.Ttext
local Sanctum = script.Parent.Frame.TextLabel
create.MouseButton1Click:Connect(function()
for i = 0, 1, .09 do
create.TextTransparency = i
Ptext.ImageTransparency = i
Rtext.ImageTransparency = i
Otext.ImageTransparency = i
Jtext.ImageTransparency = i
Etext.ImageTransparency = i
Ctext.ImageTransparency = i
Ttext.ImageTransparency = i
Sanctum.TextTransparency = i
wait(.2)
end
create.Visible = false
choice.Visible = true
end)
So just to clarify, I think the problem is that the second screen is executing its script even though the first screen is not finished doing everything. My proposition is that you can solve this by waiting for the first screen to finish through some handy event handling.
I think what you should do is create a BindableEvent if those are two different scripts, firing when the first screen completely disappears:
first screen script:
-- do first screen stuff
create.MouseButton1Click:Connect(function()
-- do the transparency thing
script.FirstScreenFinished:Fire()
end)
second screen script:
local FirstFinished = --[[first screen script]].FirstScreenFinished
FirstFinished.Event:Wait()
-- do second screen stuff
or you can put it all in one script and do all the stuff from the first screen with the stuff from the second screen script. That can get a little messy though:
-- do first screen stuff
create.MouseButton1Click:Connect(function()
-- do the transparency thing
-- do second screen stuff
end)
I think the most organized way of doing this is by creating a module script for each of your screen scripts and have a parent script that handles when their actions are executed:
local FirstScreenModule = require(script.FirstScreenModule)
local SecondScreenModule = require(script.SecondScreenModule)
local create = FirstScreenModule:Initialize() -- or something like that
create.MouseButton1Click:Connect(function()
-- these are just examples, you can make your modules any way you want lol
FirstScreenModule:Fade()
SecondScreenModule:ShowName()
end)
That can get very complicated if you don’t know what you’re doing though, so I would recommend the first or second solution.
Sorry for answering late, you can put the event anywhere you want as long as both local scripts can access it, and FirstScreenFinished is supposed to be the name of the event in my example, but you can name it so it makes sense, like say ChoiceStart or something like that.