What do you want to achieve? Player will be able to morph and go back to itself using a GUI Button.
What is the issue? Upon pressing the button, the player transforms but the camera doesn’t follow the morphed player
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
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!
local player = game.Players.LocalPlayer
local worldCamera = workspace.CurrentCamera
player:GetPropertyChangedSignal("Character"):Connect(function()
worldCamera.CameraSubject = player.Character:WaitForChild("Humanoid")
end)
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)