How to move a players camera once a part is touched?
Asked by
5 years ago Edited 5 years ago
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):
01 | local Workspace = game:GetService( "Workspace" ) |
02 | local Players = game:GetService( "Players" ) |
03 | local TweenService = game:GetService( "TweenService" ) |
04 | local CurrentCamera = Workspace.CurrentCamera |
06 | local Next = script.Parent.Parent.Parent.Parent.Shop:WaitForChild( "Next" ) |
07 | local Previous = script.Parent.Parent.Parent.Parent.Shop:WaitForChild( "Prev" ) |
12 | Finished = Workspace.Cameras [ CurrentItem ] |
13 | local TweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0 , false ) |
14 | local Goal = { CFrame = CFrame.new(Finished.Position) } |
15 | local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal) |
18 | Next.MouseButton 1 Click:connect( function () |
19 | CurrentCamera.CameraType = Enum.CameraType.Scriptable |
20 | CurrentItem = CurrentItem + 1 |
22 | if CurrentItem > 3 then |
26 | Finished = Workspace.Cameras [ CurrentItem ] |
27 | local TweenInfo = TweenInfo.new()( 1 , Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0 , false ) |
28 | local Goal = { CFrame = CFrame.new(Finished.Position) } |
29 | local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal) |
35 | Previous.MouseButton 1 Click:connect( function () |
36 | CurrentCamera.CameraType = Enum.CameraType.Scriptable |
37 | CurrentItem = CurrentItem - 1 |
39 | if CurrentItem < 1 then |
42 | Previous.Visible = true |
43 | Finished = Workspace.Cameras [ CurrentItem ] |
44 | local TweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0 , false ) |
45 | local Goal = { CFrame = CFrame.new(Finished.Position) } |
46 | local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal) |