#camera trigger
1 messages · Page 1 of 1 (latest)
Just ask chatgpt to make a template script for that
** You are now Level 2! **
Use a TouchEvent listener on the part, add a conditional to ensure it was a player that touched the part, then set the CurrentCamera.CameraSubject = Your Selected Object
You will have to change the CameraType to scriptable in order to do this so make sure to reset it when your done with manipulating the camera
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local remote = ReplicatedStorage:WaitForChild("CameraSnapEvent")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local originalType = nil
local originalSubject = nil
remote.OnClientEvent:Connect(function(targetPosition, duration)
-- Save original camera state
originalType = camera.CameraType
originalSubject = camera.CameraSubject
-- Set camera to Scriptable and focus on target
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(camera.CFrame.Position, targetPosition)
-- Optionally, smoothly update camera to keep looking at target
local startTime = tick()
local conn
conn = RunService.RenderStepped:Connect(function()
local now = tick()
if now - startTime > duration then
conn:Disconnect()
-- Restore camera
camera.CameraType = originalType
camera.CameraSubject = originalSubject
return
end
camera.CFrame = CFrame.new(camera.CFrame.Position, targetPosition)
end)
end)
is that a good one?