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
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)
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.
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.
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 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.
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.
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;