I'm trying to move the players current camera to the position of a part. I have the part where you can move between the cameras but no way to activate it when the player hits a certain part using a touched function. I also have a second problem, So say i was clicking the previous button to move to the previous item but there is no item. If you click it more than once you cant go back unless you click it untill its back to 1 the first camera. button I've been trying for about 45 minutes now and i really cant seem to figure it out. If anyone would like to support me that would be thankful of you :)
Here's my script (You click a button it moves between the Cameras):
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local CurrentCamera = Workspace.CurrentCamera
local Next = script.Parent.Parent.Parent.Parent.Shop:WaitForChild("Next")
local Previous = script.Parent.Parent.Parent.Parent.Shop:WaitForChild("Prev")
local CurrentItem = 1
local Finished = nil
Finished = Workspace.Cameras[CurrentItem]
local TweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local Goal = {CFrame = CFrame.new(Finished.Position)}
local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal)
Tween:Play()
Next.MouseButton1Click:connect(function()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentItem = CurrentItem + 1
print (CurrentItem)
if CurrentItem > 3 then
CurrentItem = 1
else
Next.Visible = true
Finished = Workspace.Cameras[CurrentItem]
local TweenInfo = TweenInfo.new()(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local Goal = {CFrame = CFrame.new(Finished.Position)}
local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal)
Tween:Play()
end
end)
Previous.MouseButton1Click:connect(function()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentItem = CurrentItem - 1
print (CurrentItem)
if CurrentItem < 1 then
CurrentItem = 2
else
Previous.Visible = true
Finished = Workspace.Cameras[CurrentItem]
local TweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local Goal = {CFrame = CFrame.new(Finished.Position)}
local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal)
Tween:Play()
end
end)
