I’m making a quick little title screen for a Iron Lung remake I’m making. But task.wait completely stops the script.
Here is the script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local modulesFolder = replicatedStorage:WaitForChild("Modules")
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local utilties = require(modulesFolder:WaitForChild("Utilities"))
local createObject = utilties.CreateObject
local tween = utilties.Tween
local titleScreen = {}
function titleScreen:InitState()
local ambience = Instance.new("Sound", workspace)
ambience.Name = "Ambience"
ambience.SoundId = "rbxassetid://5410085763"
ambience.Looped = true
if not ambience.Looped then
repeat task.wait() until ambience.Looped
end
ambience:Play()
local gui = Instance.new("ScreenGui", playerGui)
gui.Name = "TitleScreen"
gui.IgnoreGuiInset = true
local logo = createObject("TextLabel", {
Parent = gui,
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0.3, 0),
Position = UDim2.new(0, 0, 0.25, 0),
TextScaled = true,
TextColor3 = Color3.new(1, 1, 1),
Font = Enum.Font.SpecialElite,
Text = "IRON LUNG",
ZIndex = 1
})
local prompt = createObject("TextLabel", {
Parent = gui,
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0.15, 0),
Position = UDim2.new(0, 0, 0.5, 0),
TextScaled = true,
TextColor3 = Color3.new(1, 1, 1),
Font = Enum.Font.SpecialElite,
Text = "CLICK TO PLAY",
ZIndex = 1
})
local mouse = player:GetMouse()
mouse.Button1Down:Wait()
tween(prompt, {TextTransparency = 1}, 2)
task.wait(1)
tween(logo, {TextTransparency = 1}, 2)
task.wait(2)
logo:Remove()
prompt:Remove()
local fader = createObject("Frame", {
Parent = gui,
BackgroundColor3 = Color3.new(0, 0, 0),
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 1, 0),
ZIndex = 2
})
tween(fader, {BackgroundTransparency = 0}, 2)
tween(ambience, {Volume = 0}, 2)
task.wait(2)
ambience:Remove()
local introScript = require(modulesFolder:WaitForChild("IntroScript"))
introScript:PlayIntro()
tween(fader, {BackgroundTransparency = 1}, 2)
task.wait(2)
gui:Remove()
script:Remove()
end
return titleScreen
The Button1Down:Wait()
stops the script entirely aswell, but when I comment that out the script stops after the tween here:
tween(prompt, {TextTransparency = 1}, 2)
task.wait(1)
Any ideas on how to fix this?