I am making a script where the camera changes its CFrame across different parts.
The CFrame of the camera changes but I see the same thing. Here is the video:
Here is the script.
-- Varibles
local Camera = game.Workspace.CurrentCamera
local CameraFolder = game.Workspace.CameraAnchors
local CurrentValue = script:WaitForChild("CurrentValue")
-- Camera Change Function
local function ChangeCamera()
Camera.CFrame = CameraFolder:FindFirstChild("CameraAnchor"..CurrentValue.Value).CFrame
print(Camera.CFrame)
end
Camera.CameraType = Enum.CameraType.Scriptable
script.Parent.NameTextLabel.Text = CameraFolder:WaitForChild("CameraAnchor"..CurrentValue.Value).PartName.Value
ChangeCamera()
-- Button Function
local function ChangeValueButton(Left: boolean)
if Left == true and CurrentValue.Value ~= 1 then
CurrentValue.Value -= 1
ChangeCamera()
elseif Left == false and CurrentValue.Value ~= #CameraFolder:GetChildren() then
CurrentValue.Value += 1
ChangeCamera()
elseif Left == true and CurrentValue.Value == 1 then
CurrentValue.Value = #CameraFolder:GetChildren()
ChangeCamera()
elseif Left == false and CurrentValue.Value == #CameraFolder:GetChildren() then
CurrentValue.Value = 1
ChangeCamera()
end
end
-- Main Function
script.Parent.RightButton.MouseButton1Click:Connect(function()
ChangeValueButton(false)
script.Parent.NameTextLabel.Text = CameraFolder:FindFirstChild("CameraAnchor"..CurrentValue.Value).PartName.Value
end)
script.Parent.LeftButton.MouseButton1Click:Connect(function()
ChangeValueButton(true)
script.Parent.NameTextLabel.Text = CameraFolder:FindFirstChild("CameraAnchor"..CurrentValue.Value).PartName.Value
end)
Thank you for your help! ![]()