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

Can someone please tell me why this localscript doesnt zoom in on my part when I touch another part?

just so you know I set the camera to scriptable and here is the code

Tween = game:GetService("TweenService")
Vpart = game.Workspace.VisualPart
Camera = game.Workspace.CurrentCamera
local tweenInfo = TweenInfo.new(6)
local goal = {}
goal.subject = Vpart
local tween = Tween:Create(Camera,tweenInfo,goal)

part = game.Workspace.DialoguePart

part.Touched:Connect(function(itemTouchingPart)
    if(itemTouchingPart.Parent and game.Players:FindFirstChild(itemTouchingPart.Parent.Name))then
        tween:Play()
    end

end)

1 answer

✓ Accepted answer

It doesn't zoom because you didn't set the goal to zoom in on the part.

Tween = game:GetService("TweenService")
Vpart = game.Workspace.VisualPart
Camera = game.Workspace.CurrentCamera
part = game.Workspace.DialoguePart
local tweenInfo = TweenInfo.new(6)
local goal = {}
goal.CFrame = CFrame.new(Camera.CFrame.Position, Vpart.CFrame.Position) --looks at the part
goal.FieldOfView = 50 -- default is 70, it changes to 50 to "zoom in" on the part
local tween = Tween:Create(Camera,tweenInfo,goal)



part.Touched:Connect(function(itemTouchingPart)
    if(itemTouchingPart.Parent and game.Players:FindFirstChild(itemTouchingPart.Parent.Name))then
        tween:Play()
    end

end)

So to manipulate the camera positioning of the camera, you have to use CFrames, and to manipulate the zoom of the camera, you have to use the FOV.

If this answers your question, then mark it as the accepted answer, if not, then you can ask me any further questions you might have.

20 comments

0

Is there something you don't understand still? You can just ask me by replying to my answer.

0

For some reason in my game its doing the exact opposite of zooming in, do you know if this is a glitch or is there a problem with the code? I dont really know cause I haven't really worked with Cframes

0

Its zooming out? That should not happen unless you've already set your FOV to be lower than 50.

0

I haven't, Ill post video link on question

0

actually can u get on scripting helpers discord that way I can easily upload it

0

ok

0

here is video link https://youtu.be/yMFE0O-UzGY

0

sorry it took so long

0

its unlisted here is new link https://youtu.be/yMFE0O-UzGY

0

oh, the only thing I can see that would do that is if Vpart isn't where you think it is, and actually, it shouldn't be panning away like that at all.

0

just checked it out, its where it was supposed to be

0

Do you have another script controlling the camera?

0

Oh I think I know what happened, for some reason it changed the players FOV

0

not camera

0

the player's fov is in the camera, and it is as intended. You did want it to zoom, right?

0

The only way I can see this doing what it did is if the camera's cframe was suddenly moved to that part it panned to.

0

yes I wanted to zoom in but, it zooms in on the player instead of the part

0

I messaged you my discord ID via roblox messages, i'm not sure what the problem is, so it'll be easier to figure it out together there

0

could u tell me ur discord here it tags it out on Roblox

0

https://discord.gg/Yy9Bh9 here's a server we can talk through. I don't feel like its a good idea to throw around my ID wherever because last time I did that, I got spammed

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