Developer hub says that Camera:Interpolate() function is deprecated, and that you should use TweenService instead. It also provides examples on how to use TweenService with Camera:
local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local tween = TweenService:Create(
camera,
TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
CFrame = CFrame.new(0, 10, 100),
Focus = CFrame.new(0, 0, 100)
}
)
tween:Play()
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage:FindFirstChild("Cutscene1"):FireClient(player)
end
end)```
You’re touching the part multiple times, which means the Cutscene1 fires multiple times, and thus the function in the local script runs multiple times. When the first function stops running, second one is still running, but the CameraType was already switched to Custom by the first function, which is why Interpolate produces an error.
You’re right, I wrongfully applied error from the topic to that post.
Adding wait(5) will fix it.
It may fix it in 95% of cases, but it is not the correct way of fixing the real problem. @l7ura you don’t even need to fire the RemoteEvent on PlayerAdded. Instead you can just run the script when it loads instead of wrapping it in OnClientEvent.
And regarding to actual error: When the player loads, something sets CameraType back to Custom once after a certain amount of time. I haven’t found any default script that does that, so the only fix that I can suggest is adding camera.CameraType = Enum.CameraType.Scriptable before each Interpolate function:
Little nitpicks: use workspace instead of game.Workspace; making the chain of async function + wait is inefficient and you should make a function instead