I'm making a shop by using the camera and gui's, however if the page index is at 1 it will move to the second camera's position instead of the first cameras position. And if it is at the 9th one it considers it the 10th one. I'm very new to camera manipulation and am looking for some kind of answer.
This is for going forwards
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local Cameras = workspace:WaitForChild("CamParts").Shop
local index = script.Parent.Parent.PageIndex
script.Parent.MouseButton1Click:Connect(function()
if index.Value <= 10 then
script.Parent.Parent.PageIndex.Value = script.Parent.Parent.PageIndex.Value + 1
end
if index.Value > 0 then
for Num = 0.1,1,.01 do
Camera.CFrame = Cameras["Cam" .. index.Value].CFrame:lerp(Cameras["Cam" .. index.Value + 1].CFrame,Num)
game:GetService('RunService').RenderStepped:Wait()
end
end
end)
And this is for going backwards
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local Cameras = workspace:WaitForChild("CamParts").Shop
local index = script.Parent.Parent.PageIndex
script.Parent.MouseButton1Click:Connect(function()
if index.Value >= 1 then
script.Parent.Parent.PageIndex.Value = script.Parent.Parent.PageIndex.Value - 1
end
if index.Value > 0 then
for Num = 0.1,1,.01 do
Camera.CFrame = Cameras["Cam" .. index.Value].CFrame:lerp(Cameras["Cam" .. index.Value - 1].CFrame,Num)
game:GetService('RunService').RenderStepped:Wait()
end
end
end)
