Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I transfer the camera?

I have this in a local script:

player = game.Players.LocalPlayer
character = player.Character:Clone()
character.PrimaryPart = character.Torso
character:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
game.Workspace.CurrentCamera.CameraSubject = character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"

It's supposed to clone the player, then move the camera to the clone. None of this works, for some reason.

2 answers

✓ Accepted answer

Zerio, your comment is simple to fix. Change CameraName to current workspace's camera name. Wiki: The center of help and bugs too. Well, guess what there is stuff for what we dont need wiki and we need. In this case, we don't

Let's see your code and point what i've found while reading it:

player = game.Players.LocalPlayer -- Good start, but remember to make it a local variable
-- remember to make script a LocalScript
character = player.Character:Clone()
character.PrimaryPart = character.Torso
character:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
game.Workspace.CurrentCamera.CameraSubject = character.Humanoid -- ... are you serious
game.Workspace.CurrentCamera.CameraType = "Custom"

So, the player would look like this:

local player = game.Players.LocalPlayer

Well, by myself fixing this:

local player = game.Players.LocalPlayer
-- let's replace CHARACTER mess with a model.
modelm = Instance.new("Model", game.Workspace) -- For a player
modelm.Name = player.Name -- This makes the PLAYER's Character model
for _,item in pairs(player.Character:GetChildren()) do -- this will get every character item
item:clone().Parent = modelm -- this works fine
if item.ClassName == "Humanoid" then
 game.Workspace:findFirstChild("CameraName").CameraSubject = modelm.Humanoid
end
end
game.Workspace:findFirstChild("CameraName").CameraType = Enum.CameraType.Custom

Hope this fixes your problem, Thanks, marcoantoniosantos3

5 comments

0

The wiki says I should use game.Workspace.CurrentCamera when editing the player's camera... your script breaks where it says game.Workspace:findFirstChild("CameraName")

0

You should be using Workspace.CurrentCamera, and none of marco's other edits are necessary.

0

Wow, adark, but my edits worked. Stop talking bad about my scripts, please.

0

Your edits fixed the issue, but by rewriting the entire script; the only problem was that his 'character' variable was never parented to the Workspace. You also used an outdated (and broken) method of getting the camera.

0

where is it broken? it works for me adark.

As far as I can tell, you problem is that you never set character's Parent to Workspace (or Workspace.CurrentCamera), so the Camera has nothing to attach to.

This discussion is preserved as it was. New answers, comments, and votes are closed.