Camera not moving when arrows pressed

I want to make a ring select for a tower game that switches through rings if you click the forward and back buttons. I’m using tweens for this and I am moving the camera.

When I press the button, the tween doesn’t work. There are no errors, and I don’t know why it isn’t. This is what it’s supposed to do:


(poorly acted depiction haha)

This is the script:

local tweenservice = game:GetService("TweenService")
local cam = workspace.Camera
local scenes = workspace.CamScenes
local screengui = game.StarterGui.ScreenGui
local RingUp = screengui.RingUp
local RingDown = screengui.RingDown
local tween1 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["1"].CFrame})
local tween2 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["2"].CFrame})
local tween3 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["3"].CFrame})
local tween4 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["4"].CFrame})
local tween5 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["5"].CFrame})
local tween6 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["6"].CFrame})
local ringnum = 1
repeat wait() until cam.CameraSubject ~= nil
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = scenes["1"].CFrame
RingUp.MouseButton1Click:Connect(function()
	if ringnum == 1 then
		tween2:Play()
		ringnum = 2
	elseif ringnum == 2 then
		tween3:Play()
		ringnum = 3
	elseif ringnum == 3 then
		tween4:Play()
		ringnum = 4
	elseif ringnum == 4 then
		tween5:Play()
		ringnum = 5
	elseif ringnum == 5 then
		tween6:Play()
		ringnum = 6
	end
end)
RingDown.MouseButton1Click:Connect(function()
	if ringnum == 6 then
		tween5:Play()
		ringnum = 5
	elseif ringnum == 5 then
		tween4:Play()
		ringnum = 4
	elseif ringnum == 4 then
		tween3:Play()
		ringnum = 3
	elseif ringnum == 3 then
		tween2:Play()
		ringnum = 2
	elseif ringnum == 2 then
		tween1:Play()
		ringnum = 1
	end
end)

Thank you!

You can’t click a button in roblox studios (with it firing) without being in play/test mode!

I know, i was doing it in test mode but it wasn’t working, i was just trying to show what it was supposed to do

Ah, I see you are trying to make a spectator camera, hm?

Its good practices to call the camera as this:

local cam = workspace.CurrentCamera

And im not sure if this is the problem but in these lines

local tween1 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes["1"].CFrame}

You should change it to

local tween1 = tweenservice:Create(cam,TweenInfo.new(1,Enum.EasingStyle.Exponential),{CFrame = scenes[1].CFrame}

Do the same for all the six, And also change this as shown above

cam.CFrame = scenes["1"].CFrame

Listen you need to play the game in roblox studio by pressing this button
image
wait
HOW!? how are you able to use the studio when roblox is down? tell me this sorcery.

1 Like

This is the culprit, you are indexing the ScreenGui inside StarterGui and not the ScreenGui inside the player’s PlayerGui. Which is what you are actually supposed to do.

local Player = game:GetService("Players")
local PlayerGui = Player.PlayerGui
local screengui = PlayerGui.ScreenGui

You could try this, but make sure the UI is loaded for the player to make it work.

1 Like

This is maybe a lazy move. But i have used this module before and it helped me a ton: CutsceneService - Smooth cutscenes using Bézier curves

The best practice is to create something yourself. It’s a preference. Make sure to take a look tho.

1 Like

nope, it doesn’t work. I think it actually made it worse lmao.

No, I don’t want to use plugins for this lol
Thanks for trying to help though

Elaborate on what you mean worse, you were indexing for player’s gui in StarterGui which is entirely wrong. It might not have worked because you didn’t wait for the UI to load and instead just pasted the code.

2 Likes

it literally just didnt change the camera
like, i loaded up the game and the camera was on the player, not on the part.

Yes, a very old topic, I know. But there is still no answer, so I am going to give it.
In TweenInfo.new() you forgot to add the EasingDirection property, so of course it is not working.
You should change the

TweenInfo.new(1,Enum.EasingStyle.Exponential)

to

TweenInfo.new(1,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut)

Hopefully this will help anybody.

EDIT: You can also add

TweenInfo.new(1,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut,0) --added repeat count
1 Like