I want to have the player’s camera move to a part’s position for 5 seconds, then set the camera back to the player.
Here’s what I have so far:
local part = script.Parent
local camera = game.Workspace.Camera
local show = game.Workspace.Show
part.Touched:Connect(function()
camera.postiton = show.Position
end)
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
repeat Camera.CameraType = Enum.CameraType.Scriptable wait() until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = show.CFrame
end
end)
Sorry if this is confusing or anything, it just sees if the thing that hit it was actually a Player.
The camera isn’t replicated, you should be using a LocalScript. The best place for it would be StarterPlayerScripts. I may be misreading or misunderstanding, but that’s a major issue if I’m understanding correctly.
local Camera = game.Workspace.Camera
local original_CF = Camera.Cframe
--Code. Once done:
Camera.CameraType = Enum.CameraType.Custom
Camera.Cframe = original_CF
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local part = workspace:WaitForChild("Part")
userInput.InputBegan:Connect(function(key, processed)
if processed then
return
end
if key.KeyCode == Enum.KeyCode.F then
camera.CameraSubject = part
end
end)
userInput.InputEnded:Connect(function(key, processed)
if processed then
return
end
if key.KeyCode == Enum.KeyCode.F then
camera.CameraSubject = humanoid
end
end)
Here’s a simple script which focuses the client’s camera on a BasePart instance in the workspace named “Part” whenever the “F” key is pressed (and held), once the key is released the camera’s focus returns to the player’s character.