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

Cant set camera back to player?

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)

2 comments

0

is it for a start screen

0

Yes.

2 answers

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.

2 comments

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 ;-;

0

Im glad you atleast tried to help

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)

3 comments

0

I tried that but it didnt work. i think its a bug because all of these type of questions have been answered

0

Thank you for helping anyways

0

Not a problem, hope you figure out whats wrong.

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