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 manual delay)
- -- Function to create a black fade-in effect
- local function createFadeScreen(duration)
- local player = Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local fadeFrame = Instance.new("ScreenGui", playerGui)
- fadeFrame.IgnoreGuiInset = true
- local blackFrame = Instance.new("Frame", fadeFrame)
- 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()
- fadeFrame:Destroy()
- end
- -- Function to show dialogue
- local function showDialogue()
- local playerName = Players.LocalPlayer.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..."
- }
- for _, line in ipairs(dialogue) do
- print(line) -- Replace with GUI code if you want the dialogue displayed in a GUI
- task.wait(3) -- Wait time for each dialogue line
- end
- 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 and wait 30 seconds
- if i == 3 then
- showDialogue()
- task.wait(30)
- 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