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.
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)