Camera Movement On Join

hello, i have a localscript setup in the startergui. i would like to make it so that when the player joins their camera is moved to a block and their camera is facing the direction the attachment is.

ive tried lots of stuff and cannot figure this out, how do i do it?

local Tween = game:GetService("TweenService")
local Play = script.Parent.LoadFrame.Play
local Player = game:GetService("Players").LocalPlayer
local Assets = script.Parent.Assets
Assets.Loading:Play()

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
Assets.UIBlur.Parent = game:GetService("Lighting")
wait(10)

Tween:Create(Play.ButtonText, TweenInfo.new(0.2), {TextTransparency = 0}):Play()
Tween:Create(Play, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
for i,v in pairs(Play.Shadows:GetChildren()) do
	Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 0.86}):Play()
end

Play.MouseButton1Click:Connect(function()
	Tween:Create(Play.ButtonText, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(Play, TweenInfo.new(0.2), {BackgroundTransparency = 1}):Play()
	for i,v in pairs(Play.Shadows:GetChildren()) do
		Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 1}):Play()
	end
	wait(3)
	Tween:Create(Assets.Loading, TweenInfo.new(0.2), {Volume = 0}):Play()
	wait(0.2)
	Assets.Loading:Stop()
	for i,v in pairs(script.Parent.LoadFrame.Shadows:GetChildren()) do
		Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 1}):Play()
	end
	Tween:Create(script.Parent.LoadFrame, TweenInfo.new(0.2), {BackgroundTransparency = 1}):Play()
	Tween:Create(script.Parent.LoadFrame.RandomMessage, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(script.Parent.LoadFrame.Tip, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(game:GetService("Lighting").UIBlur, TweenInfo.new(0.2), {Size = 0}):Play()
	Assets.Boom:Play()
end)
3 Likes

Hey! To put a camera in a specific block/attachment you need to convert cameratype to Scriptable so you can move it in scripts.
EXAMPLE:

local Camera = game.Workspace.CurrentCamera
local CameraPoint = game.Workspace.Yourpartorattachment
Camera.CameraType = Enum.CameraType.Scriptable -- You can use the enum or the ""
Camera.CFrame = CameraPoint.Cframe

Hope this works haha.

Script is now

local Tween = game:GetService("TweenService")
local Play = script.Parent.LoadFrame.Play
local Player = game:GetService("Players").LocalPlayer
local Assets = script.Parent.Assets
Assets.Loading:Play()

local Camera = game.Workspace.CurrentCamera
local CameraPoint = script.CameraMoveTo
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CameraPoint.CFrame

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
Assets.UIBlur.Parent = game:GetService("Lighting")
wait(10)

Tween:Create(Play.ButtonText, TweenInfo.new(0.2), {TextTransparency = 0}):Play()
Tween:Create(Play, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
for i,v in pairs(Play.Shadows:GetChildren()) do
	Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 0.86}):Play()
end

Play.MouseButton1Click:Connect(function()
	Tween:Create(Play.ButtonText, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(Play, TweenInfo.new(0.2), {BackgroundTransparency = 1}):Play()
	for i,v in pairs(Play.Shadows:GetChildren()) do
		Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 1}):Play()
	end
	wait(3)
	Tween:Create(Assets.Loading, TweenInfo.new(0.2), {Volume = 0}):Play()
	wait(0.2)
	Assets.Loading:Stop()
	for i,v in pairs(script.Parent.LoadFrame.Shadows:GetChildren()) do
		Tween:Create(v, TweenInfo.new(0.2), {ImageTransparency = 1}):Play()
	end
	Tween:Create(script.Parent.LoadFrame, TweenInfo.new(0.2), {BackgroundTransparency = 1}):Play()
	Tween:Create(script.Parent.LoadFrame.RandomMessage, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(script.Parent.LoadFrame.Tip, TweenInfo.new(0.2), {TextTransparency = 1}):Play()
	Tween:Create(game:GetService("Lighting").UIBlur, TweenInfo.new(0.2), {Size = 0}):Play()
	Assets.Boom:Play()
end)

and does not work, player camera is still attached to the head

1 Like

The console throws some error?

You could try adding statements as

WaitForChild:()
``` on the camera
1 Like

The script its self doesn’t work and returns no error.

It’s able to find the camera, but just doesn’t move it.

Let me see the script. One moment

You are executing this on a LocalScript or in a Script?

it is being ran on a local script within the startergui

You set the camera’s CFrame only once at the start of script execution. Try putting this in a RS.RenderStepped connection or a loop of some sort.

I forgetted that! Try the Nexus Idea

I’m not sure how to do that at all

Heyy! Probably its because you dont wait the player loaded, Use players.PlayerAdded and wait a few seconds after putting the camera in a CFrame, Try that (Check the player added its the client)

Add this:

...
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CameraPoint.CFrame
...
Tween:Create(Camera, TweenInfo.new(5), {CFrame = CameraPoint.CFrame})

This’ll hold the camera in place for 5 seconds.

Hey! Try this, It works.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer

local Camera = game.Workspace.CurrentCamera

wait(2) -- Code waits 2 seconds to load (Remeber the GUI's in StarterGui loads when player character loads)

Camera.CameraType = Enum.CameraType.Scriptable
wait()
Camera.CFrame = game.Workspace.CamPoint.CFrame


image
image

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.