Tweening Camera not working

Greetings!

Recently i’ve created a intro camera script and everything works fine. However, the camera is pointed at a billboard which have some buttons.
Basically what i need help is with the ClickDetector. I tried to script a camera tween upon MouseClick event. I can see the clicking cursor icon when i hover over the button but when i click nothing happens. There are no errors inside output.

Here is the script :

local Button = game.Workspace.Cameras.MainMenuView.Button.ClickDetector

local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
local tween = TweenService:Create(camera,
								  TweenInfo.new(2,
												Enum.EasingStyle.Quart,
												Enum.EasingDirection.InOut),
												{CFrame = game.Workspace.Cameras.MainMenuView.Camera.CFrame,Focus = game.Workspace.Cameras.MainMenuView.Focus.CFrame})


Button.MouseClick:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	tween:Play()
end)

The camera was already scriptable so i defined the CameraType again just to be sure. Also, the camera has been scripted when the player joins. I thought that was messing with the click detector’s script but after some tries with and without i got the same results. Button working, script not working.

The script i thought it was breaking the one above


--Checking For Character--
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer


--Variables-- 
local CurrentCamera = game.Workspace.CurrentCamera
local MainIntro = script.Parent.Main
local Shade1 = script.Parent.Shade1
local Shade2 = script.Parent.Shade2

local TimeLoading = 10

player.CharacterAdded:Connect(function()
wait()
	print("Counting. Intro will begin soon!")
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	CurrentCamera.CFrame = game.Workspace.CameraFocus.CFrame
	CurrentCamera.FieldOfView = 85
		wait(TimeLoading) --time before the loading screen yeets away
		MainIntro:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2,
	false,
	nil,
	false
	)
		Shade1:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2.5,
	false,
	nil,
	false
	)
		Shade2:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2.7,
	false,
	nil,
	false
	)
end)

Thank you everyone

What type of Script is this and where? It needs to be a LocalScript in order to Tween the Camera.

2 Likes

I came back to the script after a few days and made it a LocalScript. It still doesn’t work. It’s located in ServerScriptService.
image
And i tried with and without defining the camera type

local Button = game.Workspace.Cameras.MainMenuView.Button.ClickDetector

local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
local tween = TweenService:Create(camera,
								  TweenInfo.new(2,
												Enum.EasingStyle.Quart,
												Enum.EasingDirection.InOut),
												{CFrame = game.Workspace.Cameras.MainMenuView.Camera.CFrame,Focus = game.Workspace.Cameras.MainMenuView.Focus.CFrame})


Button.MouseClick:Connect(function()
	tween:Play()
end)

I don’t know what is the problem.

LocalScripts do not run within ServerScriptService, I advise placing it within StarterPlayerScripts.

1 Like