Hello! I have this script and i’m wondering how I would lock the camera onto a moving part. I tried unanchoring the part that the camera goes to, and welding it to something else but that didn’t work as it should.
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
local cutsceneTime = 6
local tweenInfo = TweenInfo.new(
cutsceneTime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
end
game.ReplicatedStorage.Cutscene.OnClientEvent:Connect(function()
tween(game.Workspace.Test1, game.Workspace.Test2)
end)
The script works for me and it’s because you forgot to add the argument in your server script. (which is player). If it still doesn’t work, replace Camera with CurrentCamera.
I have a part which you touch that fires it for all the clients. I tried replacing game.Camera with game.CurrentCamera on line 3 but that didn’t have any effect.
You can probably use runservice.renderstepped (is an event) and then set workspace.currucentcamera to the position of the part. (Everything you put inside de renderstepped function will fire before the player’s frame updates (without fps unlockers but normal max fps 60 times/second)
Alright, so this is a pretty simple solution. All you have to do is set the camera subject to the part instance as follows:
local camera = workspace.CurrentCamera -- you should always retrieve the users camera using workspace.CurrentCamera instead of workspace.Camera
camera.CameraSubject = part1
However, I must ask, are you scripting this in a local script or a server script? If your doing it in a server script you should instead script this in in a local script. You should edit the client from a local script if the change should only effect the client.
Tell me if this doesn’t work for you and I’ll try to help further
Why do you keep using the code I write and then responding to me? First it was in this topic I created. Now this. I noticed this time that you actually changed it a bit though, which was unnecessary since the part didn’t need to be defined because it was already defined somewhere in his code. However, that’s besides the point.
To me it seems like you are trying to attract my attention. Congratulations, you have it. Let’s celebrate this occasion with you getting to the point of why you are doing so.