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

Cant set camera back to player?

Asked by 3 years ago
Edited 3 years ago

I've tried a bunch of methods, different pages, but I just CANT seem to get the camera to move back to the player! Please try to get back to me asap, it's stressing me out. this is my LOCAL script and its inside of starter player scripts.

local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
player.CharacterAdded:Wait()
camera.CameraType = Enum.CameraType.Scriptable

function CameraMove(pos1, pos2, tweenbool)
    local spd = 0
    if tweenbool == true then
        spd = 5
    end
    local info, posnx = TweenInfo.new(
        spd,
        Enum.EasingStyle.Back,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    ), {
        CFrame = CFrame.new(pos1, pos2)
    }
    local tween = TweenService:Create(camera, info, posnx)
    camera.CameraType = Enum.CameraType.Scriptable
    tween:Play()
end

CameraMove(workspace.Camera1.Position, workspace.SpawnLocate.LightPart.Position, false)

game.ReplicatedStorage.Events.BindableEvents.PlayerPressedPlay.Event:Connect(function()
    --Im trying to reset the camera HERE
end)
0
is it for a start screen sameb556 -12 — 3y
0
Yes. rookiecookie153 53 — 3y

2 answers

Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
3 years ago

There are two methods you could use to reset the camera: First, you can destroy the Camera object and I believe it should reset. If it doesn't, you can set the CameraType to Custom and set the CameraSubject to the player's humanoid.

0
It wouldnt reset the camera if i were to destroy i believe, because its setting the cframe once. Also ive tried the "CameraType to Custom and set the CameraSubject to the player's humanoid." and it didnt work ;-; rookiecookie153 53 — 3y
0
Im glad you atleast tried to help rookiecookie153 53 — 3y
Ad
Log in to vote
0
Answered by
0Vyp 14
3 years ago

You should just be able to set the camera type back to custom if i'm not mistaken. So the script should look like this:

local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
player.CharacterAdded:Wait()
camera.CameraType = Enum.CameraType.Scriptable

function CameraMove(pos1, pos2, tweenbool)
    local spd = 0
    if tweenbool == true then
        spd = 5
    end
    local info, posnx = TweenInfo.new(
        spd,
        Enum.EasingStyle.Back,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    ), {
        CFrame = CFrame.new(pos1, pos2)
    }
    local tween = TweenService:Create(camera, info, posnx)
    camera.CameraType = Enum.CameraType.Scriptable
    tween:Play()
end

CameraMove(workspace.Camera1.Position, workspace.SpawnLocate.LightPart.Position, false)

game.ReplicatedStorage.Events.BindableEvents.PlayerPressedPlay.Event:Connect(function()
    camera.CameraType = Enum.CameraType.Custom
end)
0
I tried that but it didnt work. i think its a bug because all of these type of questions have been answered rookiecookie153 53 — 3y
0
Thank you for helping anyways rookiecookie153 53 — 3y
0
Not a problem, hope you figure out whats wrong. 0Vyp 14 — 3y

Answer this question