Please help me out cuz i dont know what is the problem anymore
So i have a camera system that works as follows:
In workspace there is CameraScenes Folder
The script just runs throught them one by one and creates tween based on cframes of different Locations
Now i encounter problem where the first tween works fine but…
gets broken after
It tweens from the camera position of first camera scene towards the part of another camerascene
Checked if variables give correct info and they do
Code (Local Script)
local PlayerService = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local Player = PlayerService.LocalPlayer
local Camera = workspace.CurrentCamera
repeat wait() until script.Parent
local CameraHelper = require(script.Parent)
local CameraTween = nil
local CameraScenes = {}
local CameraSceneId = 0
local CameraEvent = game.ReplicatedStorage.NewEvents.MiscEvents.CameraEvent
local SceneRotationActive = Instance.new("BoolValue")
SceneRotationActive.Name = "SceneRotationActive"
SceneRotationActive.Parent = script.Parent.Parent.MainSystem
local function AdvanceToNextScene(PlaybackState)
CameraHelper:SetBrightness(-1) wait(CameraHelper.TweenTime)
if PlaybackState == Enum.PlaybackState.Cancelled then print("PlaybackState") return end
if not SceneRotationActive.Value then print("No Value Scene") return end
CameraSceneId = CameraSceneId + 1
if CameraSceneId > #CameraScenes then CameraSceneId = 1 end
CameraEvent:FireServer(CameraSceneId, CameraScenes)
local Scene = CameraScenes[CameraSceneId]
local CFrame1 = Scene.Location1.CFrame
local CFrame2 = Scene.Location2.CFrame
local Distance = (CFrame2.p - CFrame1.p).magnitude
Camera.CFrame = CFrame1 -- Even though i do set here a cam position to new Location1 it dont work
CameraTween = TweenService:Create(
Camera,
TweenInfo.new(math.max(Distance / 2, 8)),
{["CFrame"] = CFrame2}
)
CameraTween:Play()
CameraTween.Completed:Connect(AdvanceToNextScene)
CameraHelper:SetBrightness(0)
end
SceneRotationActive.Changed:Connect(function(Value)
if CameraTween then
CameraTween:Cancel()
end
if not Value then
print("Not Value")
CameraHelper:SetBrightness(-1, function()
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Player.Character
CameraHelper:SetBrightness(0)
CameraHelper:SetBlur(0)
end)
return
end
CameraScenes = game.workspace.CameraScenes:GetChildren()
Camera.CameraType = Enum.CameraType.Scriptable
CameraHelper:SetBlur(9)
CameraSceneId = 0
AdvanceToNextScene()
end)
Uploading a Video where u can see that First tween works as intended but then… It just keep glitching like u see afterwords