So im trying to change player’s camera orientation to the position of required part inside another object that starts a cutscene.
Method im currently using is just disabling player’s mouse, but i also want to smootly rotate camera to camera part, but i have no clue how because i barely worked with camera scripts.
So green part is a destination point where i want player’s camera to turn at.
well, you do it the same way as you tween parts cframe
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local tweenservicc = game:GetService("TweenService")
function lookatpart(part)
local tweeninfo = TweenInfo.new(1)
local cframetarget = CFrame.lookAt(camera.CFrame.Position, part.Position)
tweenservicc:Create(camera,tweeninfo,{["CFrame"] = cframetarget}):Play()
end
lookatpart(workspace.partypart)
might have some errors since I’m doing this on mobile, but should be an easy fix
The script works wonders, but I need it to work on a specific part inside of specific model because, as you can see in the screenshot above, there are many models with the same names.
Is it possible to do this with the ProxPrompt script through a function calling player?
or should call an event or smth?
step 1. Create a folder named “Events” on replicatedstorage
step 2. Create a RemoteEvent and name it “CamLookat”, then parent it to the Events folder
step 3. Use this new script
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local tweenservicc = game:GetService("TweenService")
local events = game.ReplicatedStorage.Events
local lookatevent = events.CamLookat
function lookatpart(part)
local tweeninfo = TweenInfo.new(1)
local cframetarget = CFrame.lookAt(camera.CFrame.Position, part.Position)
tweenservicc:Create(camera,tweeninfo,{["CFrame"] = cframetarget}):Play()
end
lookatevent.OnClientEvent:Connect(function(Part)
lookatpart(Part)
end)
step 4. to activate the cutscene, use this script
local events = game.ReplicatedStorage.Events
events.CamLookat:FireClient(Player,Part)
--[[ Change the Player to the player that activated the cutscene, like example.. game.Players.ILoveRoblocks and the Part to the CameraPart (the part that you want the player camera to look at!) ]]--
to make it activate using ProximityPrompt, you can do something like this
local Prompt = script.Parent -- assuming the script's parent is a ProximityPrompt
local Part = Prompt.Parent -- assuming the proximity prompt's parent is a basepart
Prompt.Triggered:Connect(function(Player)
game.ReplicatedStorage.Events.CamLookat:FireClient(Player,Part)
end)
again, i wrote this on mobile so there might be some issues
Thanks, it works great!
But it seems that i miscalculated stuff and we also need to change cam’s position.
Didn’t want to disturb you anymore, but i have zero knowledge at positioning things so it’d be nice if you also make it so it moves camera to another part intended for its position in same script.
I created another target for cam to move to:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local tweenservicc = game:GetService("TweenService")
local events = game.ReplicatedStorage.Events
local lookatevent = events.CamLookat
function lookatpart(part,partstart)
camera.CFrame = CFrame.new(partstart.Position)
task.wait()
local tweeninfo = TweenInfo.new(1)
local cframetarget = CFrame.lookAt(partstart.Position,part.Position)
tweenservicc:Create(camera,tweeninfo,{["CFrame"] = cframetarget}):Play()
end
lookatevent.OnClientEvent:Connect(function(Part,StartPart)
lookatpart(Part,StartPart)
end)
Prompt Script
local Prompt = script.Parent -- assuming the script's parent is a ProximityPrompt
local Part = Prompt.Parent -- assuming the proximity prompt's parent is a basepart
local CameraStartPos = Part.Parent -- which part should the camera position be teleported to
Prompt.Triggered:Connect(function(Player)
game.ReplicatedStorage.Events.CamLookat:FireClient(Player,Part,CameraStartPos)
end)
this should work, and don’t worry. you’re not bothering me, i have soo much free time currently so i thought I’d help