Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I transfer the camera?

Asked by
Zerio920 285 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

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") Zerio920 285 — 9y
0
You should be using Workspace.CurrentCamera, and none of marco's other edits are necessary. adark 5487 — 9y
0
Wow, adark, but my edits worked. Stop talking bad about my scripts, please. marcoantoniosantos3 200 — 9y
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. adark 5487 — 9y
0
where is it broken? it works for me adark. marcoantoniosantos3 200 — 9y
Ad
Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

Answer this question