Disparrel
(Disparrel)
January 3, 2020, 5:13pm
#1
I need help making a camera to view a certain area of the map. Such as done in Vesteria. I am not sure how to do this, I already have my script:
script.Parent.MouseButton1Click:connect(function()
game:GetService("TeleportService"):Teleport(4569003170)
end)
Is there a way to achieve doing what I need done? If so, please tell me below! Thanks!
1 Like
un1ND3X
(ice)
January 3, 2020, 5:19pm
#3
To set the camera to focus on just on part?
For that you would access the current camera, like :
local camera = workspace:WaitForChild(âCurrentCameraâ)
local target = workspace:WaitForChild(âPartâ)
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
camera.CFrame = target.CFrame
camera.FieldOfView = 46
camera:WorldToViewportPoint(target.CFrame)
1 Like
Disparrel
(Disparrel)
January 3, 2020, 5:20pm
#4
@XxELECTROFUSIONxX
Would this be done by me making a part under âcameraâ and inserting a local script into the part?
As currently, Iâve done what you told me. As has not worked.
(I donât script, this is why Iâm asking.)
un1ND3X
(ice)
January 3, 2020, 5:22pm
#5
You wont need to Parent anything to the camera , use the code in a local script in starter player scripts
Also this is just a simplified demonstration, changing the FoV is unnecessary.
Disparrel
(Disparrel)
January 3, 2020, 5:22pm
#6
Alright. Thanks so much for the help, this really helps me with what I was stuck with.
Disparrel
(Disparrel)
January 3, 2020, 5:22pm
#7
But, in starter player scripts should I still use the part and everything?
un1ND3X
(ice)
January 3, 2020, 5:23pm
#8
The part , in my code the target , will have to be left alone in workspace, weâre only referencing it for itâs CFrame and to make it the cameraâs subject.
Edit :
Put the part in workspace, yes.But remember it will only set the playerâs view to the partâs CFrame , not set it back.
Disparrel
(Disparrel)
January 3, 2020, 5:24pm
#9
So leave the local script in workspace, and the part in starter player scripts?
Iâm sorry for asking so many questions, Iâm really not good at scripting.
1 Like
Disparrel
(Disparrel)
January 3, 2020, 5:27pm
#10
What I am doing, if correct, is not working. I have the part in workspace with the script provided, and the local script in StarterPlayerScripts, and what I need done is not working? Have I done something wrong?
un1ND3X
(ice)
January 3, 2020, 5:28pm
#11
Please also make sure youâve referenced the right part (the correct name and directory in the script ) and made necessary adjustments.
Note : my provided code was just an outline of what youâd do something similar.
Disparrel
(Disparrel)
January 3, 2020, 5:29pm
#12
As I said before, I donât know how to script. But the part for the camera is just called âPartâ and the adjustments already there are fine.
EDIT:
My current script isâŚ
local camera = workspace:WaitForChild(âCurrentCameraâ)
local target = workspace:WaitForChild(âMenuMainâ)
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
camera.CFrame = target.CFrame
camera.FieldOfView = 46
camera:WorldToViewportPoint(target.CFrame)
saile515
(saile515)
January 3, 2020, 7:32pm
#13
This works for me:
local CameraPart = workspace.CameraPart
local Camera = workspace.CurrentCamera
repeat Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = CameraPart.CFrame
script.Parent.MouseButton1Click:Connect(function()
Camera.CameraType = Enum.CameraType.Custom
end)
Disparrel
(Disparrel)
January 3, 2020, 8:44pm
#14
Where are you putting the script? Is there a part in starterplayerscripts? Or the local script in starterplayerscripts? (or is the part in workspace?)
saile515
(saile515)
January 3, 2020, 8:45pm
#15
A local script in the GUI button in the menu.
Disparrel
(Disparrel)
January 3, 2020, 8:46pm
#16
Alright, is there a part though? What Iâm trying to achieve, is not spawn the player, but have a part facing a certain area of the map for the loading area. So, basically not showing the spawned character, but showing some kind of building.
saile515
(saile515)
January 3, 2020, 8:47pm
#17
Yes. You create a part in workspace named âCameraPartâ and move it to where you want the camera to be.
Disparrel
(Disparrel)
January 3, 2020, 8:48pm
#18
Alright. And if this doesnât work, Iâll come back to you.
Disparrel
(Disparrel)
January 3, 2020, 8:52pm
#19
This is my result:
Thing Iâm trying to do:
saile515
(saile515)
January 3, 2020, 8:53pm
#20
Do you get any errors in Output?
Disparrel
(Disparrel)
January 3, 2020, 8:54pm
#21