I’m trying to make an examine item feature which lets you look at items in your inventory in 3d.
But whenever I try to temporarily move the camera to a part for the ViewportFrame it just moves it to where it was when I was in studio mode.
Here’s where I left it
And here’s where it is in the game
Here’s my code which I use to move it:
local script btw
local InputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
InputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
if script.Parent.Enabled then
script.Parent.Enabled = false
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
else
script.Parent.Enabled = true
workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
workspace.CurrentCamera.CFrame = workspace.CamPart.CFrame
end
end
end
end)
Any idea on how to fix this?
Did you set your camera to scriptable?
1 Like
Try this
local InputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
InputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
if script.Parent.Enabled then
script.Parent.Enabled = false
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
else
script.Parent.Enabled = true
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = workspace.CamPart.CFrame
end
end
end
end)
Nothing changed sadly 
It just made it impossible to rotate the Sprite Cranberry. (i have a different script for rotating it)
Where are you locating this script, Is also a local?
It’s in a PlayerGui ScreenGui, and yeah it’s local
Alr, the code is working perfectly fine for me
Could you send me a .rblx file of the code working so I could import it into my place please
For some reason the code work but not properly, wait
1 Like
Alr got it!
--other declarations
local UIS = game:GetService("UserInputService")
local currentCam = game.Workspace.CurrentCamera
local newCam = game.Workspace.CamPart -- SET YOUR PART HERE
--declarations
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
--functions
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
if script.Parent.Enabled == true then
currentCam.CameraType = Enum.CameraType.Scriptable
script.Parent.Enabled = false
currentCam.CFrame = newCam.CFrame
else
script.Parent.Enabled = true
currentCam.CameraType = Enum.CameraType.Custom
currentCam.CameraSubject = humanoid
end
end
end)
Put this in your gui and remove the viewportframe
1 Like