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