Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i return the camera to the player properly?

I made the camera rotate around the part but i don't know how to make a button that would return the camera back to the player and let the player control the camera as he wishes.

i use this code to rotate the camera around the part ``local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0

while wait()do camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the angle * CFrame.new(0, 3, 10) --Move the camera backwards 5 units angle = angle + math.rad(0.1) -- speed of rotation

end

2 comments

0

Setting the CameraSubject to the player's humanoid?

0

yea

1 answer

✓ Accepted answer

Hi, assuming your using a localscript to change the players camera. This script should reset the camera.

EDIT2: [This should fix most issues]

local target = workspace.Part 
local camera = workspace.CurrentCamera 
camera.CameraType = Enum.CameraType.Scriptable 
camera.CameraSubject = target 
local angle = 0 
while wait() do 
	camera.CoordinateFrame = 
	CFrame.new(target.Position) --Start at the position of the part 
	* CFrame.Angles(0, angle, 0) --Rotate by the
end

That is your current script and at it's state it just continuously rotates the camera, so I believe that you can use a global variable to solve this

(This is the gui script)

-- once again used in a localscript

local button = script.Parent -- change this to where your gui button is
local cam = game.Workspace.CurrentCamera
shared.camRotate = false

button.MouseButton1Down:connect(function()
	cam.CameraSubject =  game.Players.LocalPlayer.Character.Humanoid
	cam.CameraType = "Custom"
	shared.camRotate = true
end)

(This is in your cam rotate script)

local target = workspace.Part 
local camera = workspace.CurrentCamera 
camera.CameraType = Enum.CameraType.Scriptable 
camera.CameraSubject = target 
local angle = 0 

while shared.camRotate == false do 
	wait()
	camera.CoordinateFrame = 
	CFrame.new(target.Position) --Start at the position of the part 
	* CFrame.Angles(0, angle, 0) --Rotate by the
end

Hopefully that fixes the issue

15 comments

0

ok i know that however when i make this script the camera comes back to the player but it still rotates around the player ad does not let the player move it as he wish.

0

I edited the post, so it should help you now :D

0

the camera renters to the player however the player has no control over it

0

So does the camera continuously rotate? If it does you might need to find a way to stop the while wait() loop that makes the camera continuously rotate for example I used a value

0

btw how do i paste my script in here XD

0

Edit your question :P

0

Ok

0

what is the problem

0

I have edited my post hopefully fixing it

0

the camera no longer rotates around the part it just freezes at the last spot i looked at when editing.

0

Hmm

0

would you mind going to a team create session with me?

0

Sure thing

0

i send you a friend request and here is the link when you accept me https://www.roblox.com/games/526230471/Vlad-DraculaTVs-Place-Number-17

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.