When Value changed Camera Manipulation wont play

  1. What do you want to achieve?
    Im trying to make it so if the value is greater than 1 then the player’s current camera will
    change to Part A.

  2. What is the issue? The script won’t work and it only works if I get rid of the value
    if statement line.

local player = game.Players.LocalPlayer
local character = player.Character
local Carrots = game.Players.LocalPlayer:WaitForChild("Carrots")


wait(1)

if Carrots.Value >1 then

local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end

local function Cutscene()
	MoveCamera(game.Workspace.Cameras.Event01.PartA, game.Workspace.Cameras.Event01.PartA, 20, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	wait(0.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
	
end

	Cutscene()
	
end

Is there any errors in your output?

1 Like

Well I tested the game out and no there isn’t any errors in the Output which is weird.

Strange. That script looks fine to me. I might make a demo of it in a baseplate and see if it works or not. Ill read through it a bit more though.

1 Like

Fixed! I wrapped a Changed event around the If statement, and now it works. I also moved around the the functions and stuff lol. But, that shouldn’t have any effect. It just looks better imo.

local player = game.Players.LocalPlayer

local character = player.Character

local Carrots = player:WaitForChild("Carrots")

local TweenService = game:GetService("TweenService")

local Camera = game.Workspace.CurrentCamera

wait(1)

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)

print("MoveCamera called")

Camera.CameraType = Enum.CameraType.Scriptable

Camera.CFrame = StartPart.CFrame

local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})

Cutscene:Play()

wait(Duration)

end

local function Cutscene()

print("Cutscene called")

MoveCamera(game.Workspace.Cameras.Event01.PartA, game.Workspace.Cameras.Event01.PartA, 20, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

wait(0.5)

Camera.CameraType = Enum.CameraType.Custom

Camera.CameraSubject = character:WaitForChild("Humanoid")

end

Carrots.Changed:Connect(function()

if Carrots.Value > 1 then

print("Greater than 1")

Cutscene()

end

end)
1 Like

Also, you can remove those print statements. I just used them for debugging.

1 Like

Thank you so much for your help and yeah sure.

1 Like