Teleport Fake NPC Player Character

Hello! So I am currently working on a fnaf game though there was one issue I had and I couldn’t find any ways to fix it. I was working on the lobby and I wanted a fake npc of the player to teleport inside the lobby. Facing the camera.

The script is a local script inside the screengui.

local PlayerCharacter = Player.Character
PlayerCharacter.Archivable = true
local PlayerCharacterNPC = PlayerCharacter:Clone()
PlayerCharacterNPC.Parent = game.Workspace
PlayerCharacterNPC.CFrame = -10.9, 4.1, -36.85de
wait(1)
PlayerCharacter.Archivable = false

CFrames are used to define both the angle and position of a Part or Attachment.

What you currently have for a CFrame is not the correct way to set it.
What is the CFrame supposed to be? Positional? Rotational? Both?

Whatever it is, use the functions provided by CFrame:

local Position_Only = CFrame.new(1, 2, 3)
local Rotation_Only = CFrame.Angles(math.rad(20), math.rad(90), 0) -- Must be in radians

local Both = Position_Only * Rotation_Only
-- OR
local Both = CFrame.new(1, 2, 3) * CFrame.Angles(math.rad(20), math.rad(90), 0)

More about CFrames here.


Also, why do you need to have the code in a LocalScript?

1 Like

I think I have a different way to achieve the same effect. I’ll make a script real quick

I need the code in a local script since this is like a section area. Where the camera faces the player and you can choose play,shop,etc

am getting the error

CFrame is not a valid member of Model “Workspace.Username”

I think I got it try this (Make sure to put a blank r15 or r6 rig in replicated storage)
(Also make sure this is in starterCharacter scripts)

local Players = game.Players
local Player = Players.LocalPlayer
local PlayerCharacter = Player.Character
local PlayerAppearance = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
--Put a blank r15 or r6 dummy in replicated storage and name it "Dummy"
local PlayerCharacterNPC = game.ReplicatedStorage.Dummy:Clone()
PlayerCharacterNPC.Parent = game.Workspace
PlayerCharacterNPC.Humanoid:ApplyDescription(PlayerAppearance)
local LookVector = PlayerCharacter.PrimaryPart.CFrame.LookVector
PlayerCharacterNPC:SetPrimaryPartCFrame(CFrame.new(-10.9, 4.1, -36.85))
PlayerCharacterNPC.PrimaryPart.CFrame = CFrame.lookAt(PlayerCharacterNPC.PrimaryPart.Position,PlayerCharacter.PrimaryPart.Position)
1 Like

Am trying to get the player not a dummy. But this also works!

and if you want it to keep pointing towards the player use a while loop when you do the Cframe.lookAt part