Tween Camera on touch not working?

trying to make the camera move when the player touches part. it is not working, here is script:

tweenservice = game:GetService("TweenService")
local Workspace = game:GetService("Workspace")
currentcamera = Workspace.CurrentCamera

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local ti = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
		local goal = script.Parent.Point.CFrame
		local animation = tweenservice:Create(currentcamera, ti, goal)
		animation:Play()
	end
end)

this came up in output:
16:35:38.929 - Stack Begin

16:35:38.929 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

16:35:38.930 - Stack End

16:35:39.015 - Unable to cast to Dictionary

Your goal is made incorrect. You would need to do something like

local goal = {CFrame = script.Parent.Point.CFrame}
1 Like

now nothing is coming up in output and nothing is happening

Sorry, do

local goal = {CameraSubject = script.Parent.Point}
1 Like

still…

Instead of

local animation = tweenservice:Create(currentcamera, ti, goal)

try

local animation = tweenservice:Create(workspace.CurrentCamera, ti, goal)
1 Like

didnt work, but this came up in output,

16:56:25.089 - Stack Begin

16:56:25.089 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

16:56:25.089 - Stack End

16:56:25.615 - TweenService:Create property named ‘CameraSubject’ cannot be tweened due to type mismatch (property is a ‘Object’, but given type is ‘Instance’)

16:56:25.617 - Stack Begin

16:56:25.618 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

16:56:25.618 - Stack End

Try

local goal = {CameraSubject = script.Parent.Point.CFrame}

I thought it would work with just the object, but I guess not. Hard to do this on website lol

1 Like

i think i dont need to say anything at this point…

output:

17:00:14.107 - Stack Begin

17:00:14.108 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

17:00:14.108 - Stack End

17:00:14.109 - TweenService:Create property named ‘CameraSubject’ cannot be tweened due to type mismatch (property is a ‘Object’, but given type is ‘CoordinateFrame’)

17:00:14.109 - Stack Begin

17:00:14.110 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

17:00:14.110 - Stack End

Alright, I took a look at my script for camera work and you will need to change a few things.
You are going to need 2 positions, 1 for where the camera is, and 1 for where you want the camera to actually be facing.
Then you want to have

local goal = {CFrame = CFrame.new(Position1, Position2)}

And that should work
Position1 being where you want it to be, Position2 being where you want it to face

1 Like

this came in output:
17:08:05.529 - Unable to cast to Dictionary

17:08:05.529 - Stack Begin

17:08:05.530 - Script ‘Workspace.Silk’s Shop Gui Trigger.Script’, Line 10

17:08:05.530 - Stack End

this is script:

tweenservice = game:GetService("TweenService")
local Workspace = game:GetService("Workspace")
currentcamera = Workspace.CurrentCamera

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local ti = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
		local goal = {CameraSubject = script.Parent.Point.CFrame}
		local animation = tweenservice:Create(workspace.CurrentCamera, 129.827, 10.95, 192.852, 130.86, 10.95, 179.404)
		animation:Play()
	end
end)

script.Parent.TouchEnded:Connect(function()
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)

also it didnt work

You need to use Vector3 for this. so

local animation = tweenservice:Create(workspace.CurrentCamera, ti, {CFrame = CFrame.new(Vector3.new(129.827, 10.95, 192.852), Vector3.new(130.86, 10.95, 179.404))
1 Like

w h y
d o e s
n o t h i n g
w o r k

I’m having a similar problem where I can’t tween the camera to move/turn left when I hover over a GUI :confused:

Lel I just found out that I was using a normal script instead of a local script so mabe that can help some of you too.

Always remember that only LocalScripts can access “CurrentCamera”, or things like “LocalPlayer”. Hence why they have something like “Local” or “Current” in their names.