Hello, the lost people
I am making a cutscene for the horror game I am working on now. But something wrong happens to my character in the cutscene. The character is cloned. Sometimes, the character loaded perfectly, and sometimes the character just looks like a dummy with black skin like the picture.
IntroScript:
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local gameArea = workspace.GameArea
local building = gameArea.HouseMap
local intro = gameArea.Intro
local outro = gameArea.Outro
local gui = script.Parent
local subtitle = gui.Subtitle
local speaker = gui.Speaker
local text
local function typeMessage(object, message, duration, target)
local textColors = {
[player.Name] = Color3.fromRGB(255, 255, 255),
Remy = Color3.fromRGB(5, 126, 255),
Warner = Color3.fromRGB(255, 47, 47)
}
text = message
speaker.Text = target
speaker.TextColor3 = textColors[target]
for i = 1, #text do
object.Text = string.sub(text, 1, i)
object.TextColor3 = textColors[target]
script.TypingSFX:Play()
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 cloneCharacter(targetChar)
targetChar:WaitForChild("Humanoid"):WaitForChild("HumanoidDescription")
targetChar:WaitForChild('HumanoidRootPart')
targetChar.Archivable = true
local clonedCharacter = targetChar:Clone()
if not clonedCharacter:WaitForChild("Humanoid"):FindFirstChild("Animator") then
local animator = Instance.new("Animator")
animator.Parent = clonedCharacter:WaitForChild("Humanoid")
end
clonedCharacter.Parent = ReplicatedStorage:WaitForChild("PlayerAvatar")
targetChar.Archivable = false
return clonedCharacter
end
ReplicatedStorage:WaitForChild("Status").Value = "Intro"
local function starting(target)
local clonedCharacter = cloneCharacter(character)
clonedCharacter.Parent = gameArea
clonedCharacter:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
script.IntroMusic:Play()
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = intro.CameraParts.CameraPart1
clonedCharacter:WaitForChild("HumanoidRootPart").CFrame = intro.CharacterPositions.CharacterPosition1.CFrame
script.GetOutOfCar:Play()
TweenService:Create(gui.FadeFrame, TweenInfo.new(2), {BackgroundTransparency = 1}):Play()
camera.CFrame = intro.CameraParts.CameraPart1.CFrame
cframeTween(camera, "Sine", 4, intro.CameraParts.CameraPart2)
subtitle.Visible = true
speaker.Visible = true
typeMessage(subtitle, "This is the house.", 0.9, target.Name)
wait(1)
typeMessage(subtitle, "Residents of the area here say there are screams from this abandoned house.", 3.6, target.Name)
wait(1)
typeMessage(subtitle, "Maybe something wrong happened to this house.", 3, target.Name)
wait(1)
cframeTween(camera, "Sine" or "Cubic", 0.4, intro.CameraParts.CameraPart3)
typeMessage(subtitle, "I need to go check.", 0.9, target.Name)
wait(1)
clonedCharacter:WaitForChild("Humanoid"):MoveTo(intro.CharacterPositions.CharacterPosition2.Position)
wait(.091)
TweenService:Create(gui.FadeFrame, TweenInfo.new(2), {BackgroundTransparency = 0}):Play()
wait(1)
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = character:WaitForChild("Humanoid")
script.IntroMusic:Stop()
subtitle.Visible = false
speaker.Visible = false
clonedCharacter.Parent = ReplicatedStorage:WaitForChild("PlayerAvatar")
character:WaitForChild("HumanoidRootPart").CFrame = building.Spawner.CFrame
clonedCharacter:Destroy()
wait(1)
TweenService:Create(gui.FadeFrame, TweenInfo.new(2), {BackgroundTransparency = 1}):Play()
ReplicatedStorage:WaitForChild("Status").Value= "Starting"
wait(20)
gui.Parent.GameGui.Status.Visible = true
typeMessage(gui.Parent.GameGui.Status, "The Infected Is here!", 1, "Warner")
wait(1)
gui.Parent.GameGui.Status.Visible = false
end
starting(player)
Please help
**NOTE:**The script is running from StarterGui/PlayerGui
