Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local camera = workspace.CurrentCamera
- local TweenService = game:GetService("TweenService")
- local Players = game:GetService("Players")
- local touchPart = workspace:FindFirstChild("Touch") -- Replace with your part name
- local isPlaying = false -- Cooldown to prevent multiple triggers
- -- Define camera parts and timings
- local cameraParts = {
- workspace.Camera1,
- workspace.Camera2,
- workspace.Camera3
- }
- local cameraTimes = {3, 4, 0} -- Seconds for tweening to each camera position (Camera3 has a manual delay)
- -- Function to create a black fade-in effect
- local function createFadeScreen(duration)
- local player = Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local fadeScreen = Instance.new("ScreenGui", playerGui)
- fadeScreen.IgnoreGuiInset = true
- local blackFrame = Instance.new("Frame", fadeScreen)
- blackFrame.Size = UDim2.new(1, 0, 1, 0)
- blackFrame.BackgroundColor3 = Color3.new(0, 0, 0)
- blackFrame.BorderSizePixel = 0
- local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear)
- local fadeTween = TweenService:Create(blackFrame, tweenInfo, {BackgroundTransparency = 1})
- fadeTween:Play()
- fadeTween.Completed:Wait()
- fadeScreen:Destroy()
- end
- -- Function to show dialogue
- local function showDialogue()
- local player = Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- -- Create a GUI for dialogue
- local dialogueGui = Instance.new("ScreenGui", playerGui)
- dialogueGui.IgnoreGuiInset = true
- local dialogueLabel = Instance.new("TextLabel", dialogueGui)
- dialogueLabel.Size = UDim2.new(0.6, 0, 0.1, 0)
- dialogueLabel.Position = UDim2.new(0.2, 0, 0.8, 0)
- dialogueLabel.BackgroundColor3 = Color3.new(0, 0, 0)
- dialogueLabel.BackgroundTransparency = 0.5
- dialogueLabel.TextColor3 = Color3.new(1, 1, 1)
- dialogueLabel.Font = Enum.Font.SourceSansBold
- dialogueLabel.TextScaled = true
- dialogueLabel.Text = ""
- dialogueLabel.Visible = true
- -- Dialogue lines
- local playerName = player.Name -- Player's name
- local dialogue = {
- playerName .. ": Hi and who are you?",
- "Rip_ahmed: I am the one who completed this game before!",
- "Rip_ahmed: I can say that you can't complete this game easily!",
- "Rip_ahmed: If you really can, so try it by yourself.",
- playerName .. ": Ok..."
- }
- -- Show each line
- for _, line in ipairs(dialogue) do
- dialogueLabel.Text = line
- task.wait(3) -- Wait time for each dialogue line
- end
- dialogueGui:Destroy() -- Remove the GUI after the dialogue ends
- end
- -- Function to play the cutscene
- local function playCutscene()
- isPlaying = true -- Start cooldown
- camera.CameraType = Enum.CameraType.Scriptable
- -- Black fade-in before cutscene starts
- createFadeScreen(2)
- for i = 1, #cameraParts do
- local targetCFrame = cameraParts[i].CFrame
- -- Create a tween for smooth movement
- local tweenInfo = TweenInfo.new(cameraTimes[i], Enum.EasingStyle.Linear)
- local tween = TweenService:Create(camera, tweenInfo, {CFrame = targetCFrame})
- tween:Play() -- Start the tween
- tween.Completed:Wait() -- Wait for the tween to finish
- -- If at Camera3, display dialogue, lock camera, and wait 16 seconds
- if i == 3 then
- camera.CFrame = cameraParts[3].CFrame
- camera.CameraType = Enum.CameraType.Scriptable -- Ensure the camera is fully locked
- showDialogue()
- task.wait(16)
- end
- end
- -- Reset the camera
- camera.CameraType = Enum.CameraType.Custom
- task.wait(4) -- Cooldown duration
- isPlaying = false -- Allow retriggering
- end
- -- Detect when the 'Touch' part is touched
- if touchPart then
- touchPart.Touched:Connect(function(hit)
- local character = hit.Parent
- if character and character:FindFirstChild("Humanoid") and not isPlaying then
- playCutscene()
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment