so I was working on a Su Tart kind of game and made 2 buttons which went back and fowardth between the story frames, Clicks is the variable and when you clicked the next button it raised the click variable by 1 and the max is 4 and if you clicked previous it would minus the click variable by 1 until 1 so I tried to make if statements to see if the clicks was at a certian number the camera would change positiotns which is a block which is the camera.
here is the script which i believe should be working.
local clicks = 1 script.Parent.MouseButton1Click:Connect(function() if clicks== 4 then script.Parent.Parent.prev.Activated = false end clicks = clicks+1 print(clicks) end) script.Parent.Parent.prev.MouseButton1Click:Connect(function() if clicks == 1 then script.Parent.Parent.prev.Activated = false end clicks = clicks-1 print(clicks) end) --checking 2 pos while true do if clicks==1 then workspace.Focushere.Position = Vector3.new(-14.077, 4.921, -10.263) end wait(0.1) end while true do if clicks == 2 then workspace.Focushere.Position = Vector3.new(-14.077, 4.921, -61.929) end wait(0.1) end while true do if clicks == 3 then workspace.Focushere.Position = Vector3.new(-14.077, 4.921, -114.426) end wait(0.1) end while true do if clicks == 4 then workspace.Focushere.Position = Vector3.new(-14.077, 4.921, -164.162) end wait(0.1) end
You should use TweenService to tween the camera. I am pretty sure there are better ways than a clicks variable, though if you really wanna do it like that you should store all the camera positions in a table and tween the camera to matching index in your table.
This answered question might also be helpful.