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

Can I get some help with my camera all up in here?

Asked by 9 years ago

So this script mostly works....


PURPOSE

Basically what this does is when you are not in the game, it takes your camera to a spectator view of the map.


WHAT WORKS

When you die, the game does take your camera successfully to the spectator view


WHAT DOESN'T WORK

When you respawn, the game does not take your camera back to the player


ADDITIONAL INFORMATION

The player's CameraMode is set to LockFirstPerson


WHAT I NEED

I need to figure out what I can do in the returnToPlayer function, in order to make it... you know... return to the player.


THE CODE

game.Players.LocalPlayer:WaitForChild("InGame")

function goToSpectate()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    workspace.CurrentCamera:Interpolate(workspace.DeadPlayerSpectatePos.CFrame, workspace.DeadPlayerSpectateFocus.CFrame, 2)
end

function returnToPlayer()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    workspace.CurrentCamera:Interpolate(game.Players.LocalPlayer.Character.Head.CFrame, game.Players.LocalPlayer.Character.Head.CFrame * CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame.lookVector.x, game.Players.LocalPlayer.Character.Head.CFrame.lookVector.y, game.Players.LocalPlayer.Character.Head.CFrame.lookVector.Z), 0.5)
    workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
    workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end

function determine(newVal)
    if newVal == true then
        returnToPlayer()
    elseif newVal == false then
        goToSpectate()
    end
end

game.Players.LocalPlayer.InGame.Changed:connect(determine)

determine(game.Players.LocalPlayer.InGame.Value)

1 answer

Log in to vote
1
Answered by 9 years ago

At the beginning of the script, put this:

repeat wait() until game.Players.LocalPlayer.Character
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid

That way, every time the character spawns, the script will reset the character's camera.

Hope this helped!

0
Thank you! This seems to have solved my problem! ChiefWildin 295 — 9y
Ad

Answer this question