Hi everyone
Im working on a horror game where i trigger a cutscene using a RemoteEvent. During the cutscene, I disable a 2D camera script, switch the camera to scriptable, show dialogue with a TextLabel, then restore the normal camera and GUI state.
Everything works except the dialogue label doesn’t appear? even though I set:
dialogueGui.Enabled = true
dialogueLabel.Visible = true
dialogueLabel.Text = "i need to go inside"
What I’ve checked:
- DialogueGui is a ScreenGui under StarterGui and gets cloned into
PlayerGui ResetOnSpawnis falseTextLabelis visible, large enough- No errors or warnings in the output
here’s the local script btw ![]()
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local cutsceneTrigger = workspace:WaitForChild("CutsceneTrigger")
local cutsceneNPC = workspace:WaitForChild("CutsceneNPC")
local animation = ReplicatedStorage:WaitForChild("CutsceneAnim")
local moveTarget = workspace:WaitForChild("MoveTarget")
local camParts = {
workspace:WaitForChild("Cam1"),
workspace:WaitForChild("Cam2"),
}
local fadeGui = player:WaitForChild("PlayerGui"):WaitForChild("FadeGui")
local blackFrame = fadeGui:WaitForChild("BlackFrame")
local dialogueGui = player:WaitForChild("PlayerGui"):WaitForChild("DialogueGui")
local dialogueLabel = dialogueGui:WaitForChild("DialogueLabel")
local camera2DTemplate = nil
local cutscenePlayed = false
local cutscenePlaying = false
local dialogueLines = {
"???: You shouldn't be here...",
"???: But it's too late now.",
}
local function showDialogue(lines)
dialogueGui.Enabled = true
dialogueLabel.Visible = true
for _, line in ipairs(lines) do
dialogueLabel.Text = line
task.wait(3)
end
dialogueLabel.Visible = false
end
local function fadeToBlack(duration)
blackFrame.BackgroundTransparency = 1
blackFrame.Visible = true
local tween = TweenService:Create(blackFrame, TweenInfo.new(duration), {BackgroundTransparency = 0})
tween:Play()
tween.Completed:Wait()
end
local function fadeFromBlack(duration)
local tween = TweenService:Create(blackFrame, TweenInfo.new(duration), {BackgroundTransparency = 1})
tween:Play()
tween.Completed:Wait()
blackFrame.Visible = false
end
local function remove2DCamera()
local char = player.Character or player.CharacterAdded:Wait()
local camScript = char:FindFirstChild("Camera2D")
if camScript then
camera2DTemplate = camScript:Clone()
camScript:Destroy()
end
end
local function restore2DCamera()
if not camera2DTemplate then return end
local char = player.Character or player.CharacterAdded:Wait()
local newScript = camera2DTemplate:Clone()
newScript.Parent = char
end
local function lockCameraTo(part, duration)
return task.spawn(function()
local startTime = tick()
while tick() - startTime < duration do
camera.CFrame = part.CFrame
RunService.RenderStepped:Wait()
end
end)
end
local function moveNPCTo(targetPos)
local humanoid = cutsceneNPC:FindFirstChild("Humanoid")
local root = cutsceneNPC:FindFirstChild("HumanoidRootPart")
if humanoid and root then
local path = PathfindingService:CreatePath()
path:ComputeAsync(root.Position, targetPos)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
end
end
local function playCutscene()
if cutscenePlaying or cutscenePlayed then return end
cutscenePlaying = true
cutscenePlayed = true
remove2DCamera()
camera.CameraType = Enum.CameraType.Scriptable
local humanoid = cutsceneNPC:FindFirstChild("Humanoid")
local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")
if humanoid and animator and animation:IsA("Animation") then
local track = animator:LoadAnimation(animation)
track:Play()
end
lockCameraTo(camParts[1], 5)
task.wait(5)
lockCameraTo(camParts[2], 5)
task.spawn(function()
showDialogue(dialogueLines)
end)
task.wait(5)
fadeToBlack(2)
task.wait(1)
camera.CameraType = Enum.CameraType.Custom
restore2DCamera()
fadeFromBlack(2)
moveNPCTo(moveTarget.Position)
cutscenePlaying = false
--------------- ISSUE ----------------
task.delay(1, function()
dialogueGui.Enabled = true
dialogueLabel.Visible = true
dialogueLabel.Text = "i need to go inside..."
end)
end
--------------- ISSUE ----------------
ReplicatedStorage:WaitForChild("StartCutscene").OnClientEvent:Connect(function()
playCutscene()
end)```