Basically what this code is meant to do is set the camera type to scriptable and set the camera cframe to a part’s cframe.
The issue is that instead of setting the camera’s cframe to the part’s cframe it just makes the camera look in the direction that the part is facing.
I’ve made sure the part is anchored and that the code is written right and I’ve even tried putting it in a while loop but it still only sets the camera to look in the direction the part is facing
Every post on the devforum I can find is either not similar enough to what I’m experiencing or they had the issue because of a mistake in their coding.
local player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
game.ReplicatedStorage.HouseEXPL.OnClientEvent:Connect(function()
player.CameraMode = Enum.CameraMode.Classic
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.ShakeCutscenePart.CFrame
print("success")
end)
Edit: So I’ve tried making it a tween and the tween moves it to the position and then as soon as its done it snaps it right back
Right click on the part, click “Show Orientation Indicator”, click it, and find the direction it is facing. Setting the camera’s CFrame to a part’s CFrame will make the camera look the same direction the front surface is.
Turning on the orientation indicator will show you the front surface. Rotate the part accordingly to where you want it to go.
The script still prints success because (assuming you wrapped the function in a pcall correctly) there’s nothing in your script that is causing any errors.
Are you running this script on the client, or the server? When exactly is it applying these changes? (e.g. when the server starts, when the character loads, etc.)
Testing your code in a local script, everything seems fine.
As long as your code is running at the right time, and isn’t conflicting anything else that may be manipulating the camera, you shouldn’t have any problems.
Ensure that the part in question is anchored and in the correct position before this code runs. If you’re still confused and unable to solve the problem, please show me the code in your server script as well as the part you are using the CFrame of.
Sometimes the camera type doesn’t set all the time, so you could try this.
local Storage = game:GetService("ReplicatedStorage")
local Plr = game:GetService("Players").LocalPlayer
local Camera = workspace.CurrentCamera
Storage.HouseEXPL.OnClientEvent:Connect(function()
repeat
Camera.CameraType = "Scriptable" -- yes you can use strings to set it, but not when checking it
task.wait() -- prevent lag
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.ShakeCutscencePart.CFrame
end)