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.
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
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)