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

Morphing works, but camera isn't moving?

Hi!,

I am working on a game whoops sorry an "experience"

In this "Experience" the player is supposed to click a model and swap bodies with the model they clicked on, I've succeeded in the changing bodies aspect but the camera refuses to move, I've tried changing the CFrame, the subject, but nothing works, If you were looking for my code it is below

--Vars
------------------------------------------------------------
local jerryModel = script.Parent
local jerryUnion = script.Parent.JerryUnion
local clickDetect = script.Parent.ClickDetector
local char = game.Workspace.Character
--Useful Funcs
------------------------------------------------------------
function cloneChar(character)
	character.Archivable = true
	local clone = character:clone()
	character.Archivable = false
	return clone
end

--Main Code
------------------------------------------------------------------
--Called when button is clicked
function onClicked(player)
	local ogchar = player.Character
	local clone = cloneChar(ogchar)
	clone.Parent=jerryModel
	clone:MoveTo(player.Character:FindFirstChild("HumanoidRootPart").Position + Vector3.new(0, 2, 0))
	jerryUnion:Destroy()
	player.Character = char
	local cam = workspace.CurrentCamera
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = player.Character.CFrame
end

--calls onClicked when Model is touched
clickDetect.MouseClick:Connect(onClicked)

If anyone could help me I would appreciate it, I've been struggling with this for a while now

2 comments

0

Did you check if your character is moving? If its not moving then thats the problem not camera

0

@acediamodn123 My char is moving, its the camera that isn't following it

2 answers

Add an offset to the CFrame of the camera. So instead of doing cam.CFrame = player.Character.CFrame do cam.CFrame = player.Character.CFrame * CFrame.new(0,2,0). I suggest you look at this article here: https://developer.roblox.com/en-us/articles/Understanding-CFrame

2 comments

0

The Camera just isn't moving, it's stuck at where my player was

0

Yup then you should use RunService to update it every frame, so it can follow the player as they move around

i wish i could help but i am not an advanced scripter yet I'm still learning about instance.new and all those stuff lol ;-;

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