Advertisement
Joriangames

Cutscene using TOUCHED Part

Aug 15th, 2022
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.38 KB | None | 0 0
  1. --[[
  2. Thanks for using this script
  3. This script was made by Joriangames/BloxianCode
  4. Want to know how to use this and script explanation?
  5. Check the video here: https://youtu.be/iegUPV-wMng
  6. ]]
  7. --CUTSCENE HANDELER by BloxianCoder
  8. local TouchPart = workspace.Part --Put here the part the player has to touch in order to get the cutscene playing
  9.  
  10. local player = game.Players.LocalPlayer
  11. local char = player.Character or player.CharacterAdded:Wait()
  12. local hum = char:WaitForChild("Humanoid")
  13. local TransitionScreen = script.Parent.TransitionScreen
  14.  
  15. local CutsceneFolder = workspace.CutsceneSetup
  16.  
  17. local TweenService = game:GetService("TweenService")
  18.  
  19. local cam = workspace.CurrentCamera
  20.  
  21. local function startCutscene()
  22.     cam.CameraType = Enum.CameraType.Scriptable
  23.     script.Parent.Sounds.BackgroundSound:Play()
  24.    
  25.     script.Parent.TextFrame.Visible = true
  26.  
  27.     hum.WalkSpeed = 0
  28.     hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
  29. end
  30.  
  31. local function posCamera(Position)
  32.     cam.CFrame = Position
  33. end
  34.  
  35. local function posAvatar(character, position)
  36.     character.Parent = workspace
  37.     character.HumanoidRootPart.CFrame = position
  38. end
  39.  
  40. local function TweenCam(newPosition, delayTime)
  41.     local CamTweening = TweenService:Create(cam, TweenInfo.new(delayTime), {CFrame = newPosition})
  42.     CamTweening:Play()
  43. end
  44.  
  45. local function ChangeName(nametext, color)
  46.     local NameLabel = script.Parent.TextFrame.CharName
  47.     NameLabel.Text = nametext
  48.    
  49.     if color then
  50.         NameLabel.TextColor3 = color
  51.     end
  52. end
  53.  
  54. local function ChangeText(msg, color)
  55.     local Talkinglabel = script.Parent.TextFrame.BehindTalking.Talking
  56.    
  57.     if color then
  58.         Talkinglabel.TextColor3 = color
  59.     end
  60.    
  61.     for i=1, #msg do
  62.         Talkinglabel.Text = string.sub(msg, 1, i)
  63.         wait(0.1 / #msg)
  64.     end
  65. end
  66.  
  67.  
  68.  
  69. --[CUTSCENE SCRIPT STARTS HERE]
  70. TouchPart.Touched:Connect(function()
  71.    
  72.     startCutscene()
  73.     posCamera(CutsceneFolder.CamPos.CFrame)
  74.     posAvatar(char, CutsceneFolder.PlayerPos.CFrame)
  75.  
  76.  
  77.     ChangeName(player.Name, Color3.new(255, 255, 255))
  78.     ChangeText("So you wanted to know how to do this right? Well listen..", Color3.new(0.356863, 0.368627, 0.615686))
  79.     wait(5)
  80.  
  81.     TweenCam(CutsceneFolder.CamPos2.CFrame, 0.5)
  82.     ChangeName("Owner", Color3.new(0.0745098, 0.211765, 1))
  83.     ChangeText("You just have to subscribe to stay up-to-date with the latest videos", Color3.new(255, 255, 255))
  84.     wait(5)
  85.  
  86.     TweenCam(CutsceneFolder.CamPos3.CFrame, 0.5)
  87.     ChangeName("Enjoy", Color3.new(0.0745098, 0.211765, 1))
  88.     ChangeText("Enjoy the game, don't forget to like it!", Color3.new(255, 255, 255))
  89.     wait(2)
  90.  
  91.  
  92.  
  93.  
  94.     --END OF CUTSCENE. Sets camera and player to normal settings
  95.     script.Parent.TextFrame.Visible = false
  96.  
  97.     for i = 1,0,-.1 do
  98.         TransitionScreen.BackgroundTransparency = i
  99.         wait(.1)
  100.     end
  101.  
  102.     script.Parent.Sounds.BackgroundSound:Stop()
  103.     char.HumanoidRootPart.CFrame = workspace.CutsceneSetup.StartLocation.CFrame
  104.  
  105.  
  106.     cam.CameraType = Enum.CameraType.Custom
  107.     cam.CameraSubject = hum
  108.     cam.FieldOfView = 70
  109.  
  110.     hum.WalkSpeed = 16
  111.     hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
  112.  
  113.  
  114.     for i = 0,1,.1 do
  115.         TransitionScreen.BackgroundTransparency = i
  116.         wait(.1)
  117.     end
  118.  
  119. end)
  120.  
  121. script.Parent.Enabled = false
  122. script.Disabled = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement