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

Camera.CameraSubject wont change with morph script I made?

So I'm making a require script, and it seems that when I change the player.Character property, the CameraSubject of workspace.CurrentCamera doesn't change with it, so the camera never moves. Could anyone help? Here is my script that gets cloned to the character:

local Player
ParentIsPlayer = pcall(function() Player = game.Players[script.Parent.Name] end)
local NewCharacter = script.char
if ParentIsPlayer == true then
	print("playerisparent")
	local OldCharacter = Player.Character or Player.CharacterAdded:Wait()
	local OldPos = OldCharacter:GetPrimaryPartCFrame()
	NewCharacter.Name = Player.Name
	NewCharacter.Parent = workspace
	Player.Character = NewCharacter
	NewCharacter:SetPrimaryPartCFrame(OldPos)
else
	print("playerisnotparent")
end

4 comments

0

workspace.CurrentCamera.CameraSubject = NewCharacter.Humanoid

0

nope this is a SERVER script.

0

If this is a server script, then keep in mind that CurrentCamera is a property set only on the local side. On the server, CurrentCamera is always nil.

0

I tried setting up a remote event but the client never responds :/

1 answer

when you realise you can clone a script with code that creates a connection with currentcamera and the new humanoid

local wai = script:WaitForChild("playername")
if game.Players:FindFirstChild(script.Parent.Name) and game.Players.LocalPlayer.Name == wai.Value then
	local p = game.Players.LocalPlayer
	print(p)
	workspace.CurrentCamera.CameraSubject = script.Parent.Humanoid
end

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