MORPHING - Camera doesn't follow the morphed player

  1. What do you want to achieve? Player will be able to morph and go back to itself using a GUI Button.

  2. What is the issue? Upon pressing the button, the player transforms but the camera doesn’t follow the morphed player

  3. What solutions have you tried so far? I got an idea here that is from this topic → GUI button morphs a player into a model (How to do it?)
    It wasn’t my first code, but I tried changing to it as it works better. I also have tried experimenting with camera.Focus and camera.CFrame but I can’t find the solution

The Problem

My explorer
image

The code of the Local Script inside the button

local textButton = script.Parent

local MorphEvent = game.ReplicatedStorage:WaitForChild("MorphEvent")

local function onActivated()	
	MorphEvent:FireServer('Hi')
end

textButton.Activated:Connect(onActivated)

The code of the Server Script under ServerScriptService

local ReplicatedStorage = game.ReplicatedStorage
local MorphEvent = Instance.new("RemoteEvent", ReplicatedStorage)
MorphEvent.Name = "MorphEvent"

function onMorphEventFired(callingPlayer, requestedMorphName)
		local newBody = game.ServerStorage:FindFirstChild('Hi'):Clone()
	    newBody.Parent = game.Workspace
		newBody:MoveTo(callingPlayer.Character.HumanoidRootPart.Position)

		callingPlayer.Character = newBody
	end


MorphEvent.OnServerEvent:Connect(onMorphEventFired)

I am not an expert, so thank you so much for the help!

In your client code, try this:

local player = game.Players.LocalPlayer
local worldCamera = workspace.CurrentCamera

player:GetPropertyChangedSignal("Character"):Connect(function()
worldCamera.CameraSubject = player.Character:WaitForChild("Humanoid")
end)

It doesn’t do anything. I put it like this

local textButton = script.Parent
local MorphEvent = game.ReplicatedStorage:WaitForChild("MorphEvent")
local player = game.Players.LocalPlayer
local worldCamera = workspace.CurrentCamera

player:GetPropertyChangedSignal("Character"):Connect(function()
	worldCamera.CameraSubject = player.Character:WaitForChild("Humanoid")
end)

local function onActivated()	
	MorphEvent:FireServer('Hi')
end

textButton.Activated:Connect(onActivated)

I also tried putting it into another localscript

change your cameratype to custom instead of fixed

Thanks, @C_Sharper, and @Mister33j for your help!

For anyone having the same problem:

The code in a LocalScript under StarterPlayer → StarterPLayerScripts

local player = game:GetService("Players").LocalPlayer

player:GetPropertyChangedSignal("Character"):Connect(function()
	worldCamera.CameraType = Enum.CameraType.Custom
	worldCamera.CameraSubject = workspace:WaitForChild("Hi").Head
end)

The “Hi” is the name of my model that is from ServerStorage and moved to Workspace upon pressing the morphing button

The worldCamera.CameraType = Enum.CameraType.Custom is not needed if your camera type is custom already

1 Like