Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make camera position change ?

Asked by
PPJASK 19
3 years ago

Hi i want make this : part = game.Workspace.Part button = script.Parent button2 = game.StarterGui.ScreenGui.TextButton if button press then camera position = part position and if player click button2 then normal camera -Thank you and best regards ! -PPJASK

3 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Use camera manipulation

local cam = game.Workspace.CurrentCamera -- gets current camera
local part = game.Workspace.Part -- your part
local player = game.Players.LocalPlayer -- player
button.MouseButton1Click:Connect(function() -- on click
    cam.CameraType = Enum.CameraType.Scriptable -- makes camera abide by script
    cam.CFrame = part.CFrame -- Cframe is rotation and position
end)
button2.MouseButton1Click:Connect(function() -- on click
    cam.CameraType = Enum.CameraType.Custom -- custom camera (player choice)
    cam.CFrame = workspace[player.Name]:WaitForChild("HumanoidRootPart").CFrame -- player's humanoidrootpart cframe
end)
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here's a more optimized version of Omq_ItzJasmin's code (Remember to put it in a LocalScript):

local camera = workspace.CurrentCamera

local pos = Vector3.new(1,1,1)

camera.CFrame = CFrame.new(pos)
Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago

Read the API documentaion here.

Answer this question