Cutscene Script Help

Hi, everyone! So, I took this model for a cutscene from a youtube video, and was wondering how I would make it so it activates ONLY when a specific part is touched. Right now it starts when you immediately start the game. I tried with an “if” statement where if the part is touched, it then does it, but didn’t work.

All help is appreciated! <3

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TweenService = game:GetService("TweenService")

local camera = workspace.CurrentCamera

local cutsceneThings = workspace.CutsceneThings

local cutsceneStorage = ReplicatedStorage:WaitForChild("CutsceneStorage")

local sceneGui = script.Parent.Parent

local function setup()

camera.CameraType = Enum.CameraType.Scriptable

camera.FieldOfView = 60

sceneGui.Enabled = true

script.Music:Play()

end

local function positionCamera(pos)

camera.CFrame = pos

end

local function tweenCamera(endPos, tweenTime)

local camTween = TweenService:Create(camera, TweenInfo.new(tweenTime), {CFrame = endPos})

camTween:Play()

end

-- function setupCharacter()

--if character then

-- local avatar = character:Clone()

--avatar.Parent = workspace.CutsceneGameFolder

--avatar.Name = "Avatar"

--avatar.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None

--return avatar

--else

--return nil

--end

--end

local function positionRig(rig, target)

rig.Parent = workspace

rig.PrimaryPart.CFrame = target

end

local function moveRig(rig, target)

rig.Humanoid:MoveTo(target.Position)

end

local function animateRig(rig, animation, toggle)

if toggle == true then

if rig and animation then

if rig.Humanoid then

animation:Play()

end

end

elseif toggle == false then

if rig and animation then

if rig.Humanoid then

animation:Stop()

end

end

end

end

local function setText(label, msg, color)

sceneGui.Text[label].Text = msg

if color then

sceneGui.Text:FindFirstChild(label).TextColor3 = color

end

end

local function typeText(label, msg, typeTime, color)

if color then

sceneGui.Text:FindFirstChild(label).TextColor3 = color

end

for i=1, #msg do

sceneGui.Text[label].Text = string.sub(msg, 1, i)

wait(typeTime / #msg)

end

end

setup()

positionCamera(cutsceneThings.AvatarCam.CFrame)

humanoid.WalkSpeed = 0

humanoid.JumpPower = 0

positionRig(player.Character, cutsceneThings.AvatarPos.CFrame)

--local avatar = character:Clone()

--avatar.Name = "Avatar"

--avatar.Parent = workspace.CutsceneGameFolder

--positionRig(avatar, cutsceneThings.AvatarPos.CFrame)

setText("CharacterName", player.Name, Color3.new(1, 1, 1))

typeText("CutsceneText", "Hello, This is me, ".. character.Name, .1, Color3.new(1, 1, 1))

wait(5)

humanoid.WalkSpeed = 0

humanoid.JumpPower = 0

tweenCamera(cutsceneThings.AvatarCam2.CFrame, 0.25)

setText("CharacterName", "???", Color3.new(0.313725, 0.313725, 0.313725))

typeText("CutsceneText", "This is T.F.R Speaking, Who is this-?", .6, Color3.new(0.313725, 0.313725, 0.313725))

humanoid.WalkSpeed = 0

humanoid.JumpPower = 0

wait(5)

tweenCamera(cutsceneThings.AvatarCam3.CFrame, 1.60)

setText("CharacterName", player.Name, Color3.new(1, 1, 1))

typeText("CutsceneText", "What do you want from me..?", .6, Color3.new(1, 1, 1))

humanoid.WalkSpeed = 0

humanoid.JumpPower = 0

wait(5)

TweenService:Create(sceneGui.Frame, TweenInfo.new(1), {BackgroundTransparency = 0}):Play()

sceneGui.Text.Visible = false

script.Music:Stop()

wait(5)

camera.CameraType = Enum.CameraType.Custom

camera.CameraSubject = humanoid

camera.FieldOfView = 70

TweenService:Create(sceneGui.Frame, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()

character.HumanoidRootPart.CFrame = workspace.GameFolder.PlayerSpawn.CFrame

wait(1)

humanoid.WalkSpeed = 16

humanoid.JumpPower = 50

ReplicatedStorage.Remotes.JoinGame:FireServer()

sceneGui.Enabled = false

for i, v in pairs(workspace.CutsceneGameFolder:GetChildren()) do

if v:IsA("Model") or v:IsA("Part") then

v:Destroy()

end

end

sceneGui.Parent.GameGui2.Enabled = true

sceneGui.Parent.TimerGui.Enabled = true

script.Disabled = true
4 Likes

Have you ever used the .Touched Event before?

For example:

Script.Parent.Touched:Connect(function(hit)
     if hit.Parent.Humanoid then
          -- Code here
     end
)

The thing most likely touching the part is going to be the feet so that would working in this situation!

1 Like

Where exactly am I supposed to put that?

Alright, I’ll wait, hope it all goes smoothly, cause I am STILL super confused.