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

Camera Script Not Focusing On Brick?

Asked by 5 years ago

Hello guys I am trying to make the camera focus on this brick with this script but it is not focusing on the brick I am not sure why is that. When the client clicks on the button the camera just goes and focuses on a random spot on the map. The Brick that the camera is supposed to be focusing on is called CameraForOutfit. Also I am trying to make it so when the client clicks on a gui button the camera goes back to normal as it was before the client clicked the button. But I am not sure were to start with it. thanks in return.

local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera

local offset = Vector3.new(5,5,5) 

function updateCam()
    camera.CFrame = CFrame.new(workspace.CameraForOutfit.Position + offset,workspace.CameraForOutfit.Position)
end

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent:Destroy() -- Clears Gui
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CameraSubject = workspace.CameraForOutfit
    RunService:BindToRenderStep("CameraForOutfit",1,updateCam)
end)

1 answer

Log in to vote
0
Answered by 5 years ago

Try using the Camera.Focus Function. Here's an article about it that might be to help. That's what I used when I had a similar goal to yours.

https://www.robloxdev.com/api-reference/property/Camera/Focus

This is a previous answer I gave somebody else.

0
The link is blank mate and thank you for helping Flognaw3210 25 — 5y
0
If its the answer please tick it as correct. casper123123123 357 — 5y
Ad

Answer this question