Trouble Tweening the player camera

This is one of my first times Tweening, and I’m not really getting it yet. I’m trying to Tween the player’s camera to a part in the Workspace when they trigger a Proximity Prompt. I’ve looked up a couple videos and made the code for it. When I activate the Proximity Prompt, my camera doesn’t Tween, and there is no error in the output. Can someone tell me what I did wrong here?

local WorkspaceService = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")

local CurrentCamera = WorkspaceService.CurrentCamera

script.Parent.Triggered:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	local TI = TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
	local Goal = {CFrame = WorkspaceService.End.CFrame}
	local Animation = TweenService:Create(CurrentCamera, TI, Goal)
	Animation:Play()
end)

Edit: Updated the code, made it easier to read and fixed a few things. Still doesn’t work.

1 Like

well you never played the tween

local Anim = TweenService:Create(CurrentCam, TS, {CFrame = Camera.CFrame})
Anim:Play()
1 Like

Huh, none of the videos I watched showed that part… It still doesn’t work, though.

1 Like

Is this in a server script? Because if it is then it will only affect the servers camera and does not replicate to players. You have to do the camera animations on the client. You could use a remote event and fire it whenever the proximity prompt is triggered and have the client do camera manipulation. Or setup the triggered event on the client all together.

-- server
prompt.Triggered:Connect(function(player) -- it passes the player who triggered it
    remote_event:FireClient(player)
end)
-- client
remote_event.OnClientEvent:Connect(function()
    CurrentCam.CameraType = Enum.CameraType.Scriptable
    local TS = TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
    local Anim = TweenService:Create(CurrentCam, TS, {CFrame = Camera.CFrame})
    Anim:Play() -- dont forget to play it
end)
1 Like

Yeah, it’s in a local script. I don’t think I understand remote events enough to make a remote event script though.

well is the Parent even being triggered? and dude you gotta use :Play() for the tween you created using TweenService:Create

post deleted by author

try this:
local script in starterpack


local TweenService = game:GetService("TweenService")

local CurrentCamera = WorkspaceService.CurrentCamera

game.Workspace.Part.ProximityPrompt.Triggered:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	local TI = TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
	local Goal = {CFrame = game.Workspace.End.CFrame}
	local Animation = TweenService:Create(CurrentCamera, TI, Goal)
	Animation:Play()
end)

one part is in workspace
and another part name end in workspace

I’m not an idiot, of course its being triggered. And the code is playing the Tween.

Yes, that worked, thanks! I’ve also learned a lot about Tweening through this problem too, so yay I guess lol

1 Like