I made a script that interplolates the Player's camera to a brick's position,but it goes inside the brick I want it to go outside of brick,how can I do this?
What I mean when it goes inside and how I want it to be.
Script that inserts a local script into a character:
01 | local Part = script.Parent.Part |
02 | -------------------------- |
03 | Part.Touched:connect( function (part) |
04 | FoundCopy = part.Parent:FindFirstChild( "CameraScript" ) |
05 | if not FoundCopy then |
06 | for _,Scripts in pairs (script:GetChildren()) do |
07 | Cloned = Scripts:Clone() |
08 | Cloned.Parent = part.Parent |
09 | Cloned.Disabled = false |
10 | end |
11 | end |
12 | end ) |
Localscript:
01 | local Player = game.Players.LocalPlayer |
02 | local Character = Player.Character |
03 | local Camera = game.Workspace.CurrentCamera |
04 | local Part = game.Workspace.Model.Part |
05 | local Part 1 = game.Workspace.Model.Part 1 |
06 | ------------------------------------------- |
07 | Camera.CameraType = "Scriptable" |
08 | Camera:Interpolate(CFrame.new(Part.CFrame.p) ,CFrame.new(Part.CFrame.p/Part.CFrame.p), 1 ) |
09 | wait() |
10 | Camera.InterpolationFinished:connect( function () |
11 | Camera.CameraSubject = Part |
12 | Camera.CameraType = "Watch" |
13 | end ) |
1. You don't need to get the Vector3 of a CFrame when using Camera interpolation
2. You can offset the CFrame of it. I showed an example by doing an offset of -5 on the X axis.
01 | local Player = game.Players.LocalPlayer |
02 | local Character = Player.Character |
03 | local Camera = game.Workspace.CurrentCamera |
04 | local Part = game.Workspace.Model.Part |
05 | local Part 1 = game.Workspace.Model.Part 1 |
06 | ------------------------------------------- |
07 | Camera.CameraType = "Scriptable" |
08 | Camera:Interpolate(Part.CFrame * CFrame.new(- 5 , 0 , 0 ) ,Part.CFrame, 1 ) |
09 | wait() |
10 | Camera.InterpolationFinished:connect( function () |
11 | Camera.CameraSubject = Part |
12 | Camera.CameraType = "Watch" |
13 | end ) |