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

how do i return the camera to the player properly?

Asked by 7 years ago
Edited 7 years ago

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

0
Setting the CameraSubject to the player's humanoid? Thundermaker300 554 — 7y
0
yea Vlad_DraculaTV -2 — 7y

1 answer

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

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

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. Vlad_DraculaTV -2 — 7y
0
I edited the post, so it should help you now :D User#16405 0 — 7y
0
the camera renters to the player however the player has no control over it Vlad_DraculaTV -2 — 7y
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 User#16405 0 — 7y
View all comments (11 more)
0
btw how do i paste my script in here XD Vlad_DraculaTV -2 — 7y
0
Edit your question :P User#16405 0 — 7y
0
Ok User#16405 0 — 7y
0
what is the problem Vlad_DraculaTV -2 — 7y
0
I have edited my post hopefully fixing it User#16405 0 — 7y
0
the camera no longer rotates around the part it just freezes at the last spot i looked at when editing. Vlad_DraculaTV -2 — 7y
0
Hmm User#16405 0 — 7y
0
would you mind going to a team create session with me? Vlad_DraculaTV -2 — 7y
0
Sure thing User#16405 0 — 7y
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 Vlad_DraculaTV -2 — 7y
0
ok User#16405 0 — 7y
Ad

Answer this question