Need help with CutsceneScript

Hello, the lost people,

I am working on my own horror game coming out next week. But I need help with the CutsceneScript. After I pressed the play button to test the script, this error pop up at the output

Hope I can fix this ASAP

Script:

local TweenService = game:GetService("TweenService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera

local gameArea = workspace.GameArea
local intro = gameArea.Intro

local gui = script.Parent
local subtitle = gui.Subtitle
local speaker = gui.Speaker
local text

local function playSfx()
	local sfx = script.TypingSFX:Clone()
	sfx:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		sfx:Destroy()
	end))
end

local function typeMessage(message, duration, target)
	text = message
	speaker.Text = target
	for i = 1, #text do
		subtitle.Text = string.sub(text, 1, i)
		playSfx()
		subtitle.TextColor3 = Color3.fromRGB(255, 255, 255)
		wait(duration /#text)
	end
end

local function cframeTween(object, style, duration, target)
	local info = TweenInfo.new(
		duration,
		Enum.EasingStyle[style],
		Enum.EasingDirection.InOut
	)
	
	local tween = TweenService:Create(object, info, {CFrame = target.CFrame})
	tween:Play()
	tween.Completed:Wait()
end

local function starting(target, targetChar)
	local clonedCharacter = targetChar:Clone()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CameraSubject = intro.CameraParts.CameraPart1
	clonedCharacter.Parent = gameArea
	clonedCharacter:WaitForChild("HumanoidRootPart").CFrame = intro.CharacterPositions.CharacterPosition1.CFrame
	camera.CFrame = intro.CameraParts.CameraPart1.CFrame
	cframeTween(camera, "Sine", 4, intro.CameraParts.CameraPart2.CFrame)
	typeMessage("This is the house", 1, target.Name)
	wait(1)
	typeMessage("Residents of the area here say there are screams from this abandoned house", 4, player.Name)
	wait(1)
	typeMessage("They also said that the house had occupants who rarely left the house", 4.8, player.Name)
end

starting(player, character)

NOTE:This script is running from StarterGui

The error is saying that clonedCharacter's value is nil. I am pretty sure characters can’t be cloned the normal way, and require an extra function to do so.

I just read the Instance.Archivable, is that mean I need to make

clonedCharacter.Archivable = false too?

You’re close :slight_smile:

I would add this function to your code somewhere

local function cloneCharacter(char)
    char.Archivable=true
    local clone = char:Clone()
    char.Archivable = false
    return clone
end

Then, in your starting function, replace line 48 with the following:

local clonedCharacter = cloneCharacter(targetChar)

Make sure that you set the Parent of the clonedCharacter somewhere!

Apologies, this still seems to not work. I am going to find a way to clone the character another way, but that is your issue. The targetChar is not cloning.

yeah, I tried it and this message pop up in my output

Nevermind, I just realized this whole time the reason I haven’t been able to clone myself in studio was because I wasn’t parenting the clone to the workspace :man_facepalming: But you still have to use the function I gave you before. It seems like what I gave you eliminated that error that you were having, but now you are having another problem (on line 59). According to the warning you received, it is unable to find the HumanoidRootPart in the clone.

Can you show me a screenshot of the explorer (from the client view) while testing? I want to see a screenshot of the clone inside the explorer, and make sure to open the children.

You might also need to make sure that all the descendants of the character are fully loaded in before making the clone. If not, things like missing shirts and textures could occur. Consider either making a way to check if it is fully loaded, or simply adding a wait function for less than a second to delay the start of starting function.

image this is the explorer after I press the play button

Seems like the clone has no children and is completely empty. My only thought is your character isnt fully loaded when it is cloned, resulting in an unfinished clone.

Maybe make the function start on a one-second delay. Or, if you want to make it even better, you could make a way to check if the character is fully loaded, which seems like a pain to do. But for now that is last resort if the delay doesn’t work.

i tried to edit your code:

image

Also didnt work :'D

local function cloneCharacter(Character)
	Character:WaitForChild'HumanoidRootPart'; -- wait for root part to load
	Character.Archivable = true; -- set archivable to true
	
	local Clone = Character:Clone(); -- make a clone of the character
	Character.Archivable = false -- set archivable back to false
	
	return Clone -- return the cloned character
end;

Oh, I forget about something. The code is working but the animation is gone. How do I add the animation?

And also, the character didn’t load perfectly