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

Why wont camera manipulation work sometimes?

So I have a main Menu and with camera manipulation. So like when you click play it resets the camera to the player but sometimes its not working and sometimes it does work.

Script for playbutton:

--variables--
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer



--Scripts--
script.Parent.MouseButton1Click:Connect(function()
	Camera.CameraType = "Custom"
		if Player.Character and Player.Character:FindFirstChild("Torso")then
			Player.Character.Torso.CFrame = CFrame.new("Torso")
		end	
end)

Output: 15:42:10.382 - Players.Wolf_oYT.PlayerGui.MainMenu.MainFrame.PlayButton.LocalScript:11: bad argument #1 (Vector3 expected, got string)

1 answer

✓ Accepted answer

Hello. CFrame requires a Vector3 value, not a string. I'm assuming you wanted the camera CFrame to change to the player's torso's CFrame. Try this:

--variables--
local Camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer

--Scripts--
script.Parent.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom

	if Player.Character and Player.Character:FindFirstChild("Torso")then
		Player.Character.Torso.CFrame = Player.Character.Torso.CFrame
	end 
end)

2 comments

0

Thank you so much!

0

No problem.

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