Why doesn't this set the camera to the player?

When you set the camera to Fixed, it makes the player’s camera stationary.

1 Like

Wouldn’t that make it so the player is unable to move their camera? I want it so that it sets the camera to the player, and continues to be like that.

Setting the camera type to fixed unfortunately provides the same results as custom.

Is there a way to disable the tween in the other script?

I have no idea how to pause the tween as soon as the button is pressed, but would constant “if” statements work?

I don’t know how to use module scripts but this discussion may help you.

https://devforum.roblox.com/t/running-functions-in-a-different-script-than-the-one-i-created-it-in/

Not exactly what I’m looking for… I’m trying to make the player’s camera change on click. Thanks anyways!

I also tried adding the function to the camera tween script, but it didn’t work.

Maybe add these lines of code under the camera.CameraType = Enum.CameraType.Custom?

local player = game.Players.LocalPlayer
local character = workspace:FindFirstChild(player.Name)
if character then
	camera.CameraSubject = character
end

You can modify this code to however you like. I hope this helps!

1 Like

Unfortunately that also provides the same results.

Just a quick question, is your character in the workspace during this time period?

Correct. The humanoid’s walkspeed is 0 though.

If you’re currently in Studio, can you test play and try going to the properties in Workspace => Camera => CameraSubject, and change the CameraSubject to your character after your tween is finished and see if it works?

1 Like

I checked the CameraSubject, and it is the humanoid, even when the tween is running, and after the tween, it’s the same.

Sorry if this is too much, but you mind showing a short clip of it?

I’d prefer not to. Could you maybe inspect my code again?
I think the issue is that the button is pressed during a tween, but I don’t know how to solve that.

So maybe make the tween variable visible to the whole script?

local tween = nil
local forcestop = false
local tweeninfo = TweenInfo.new(
	sceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true,
	0
)

function tween(camera1, camera2, ending)
	if forcestop == false then
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = camera1.CFrame

		tween = TweenService:Create(camera, tweeninfo, {CFrame = camera2.CFrame})
		tween:Play()

		tween.Completed:Wait()

		if ending then
			camera.CameraType = Enum.CameraType.Custom
			local character = workspace:FindFirstChild(player.Name)
			if character then
				camera.CameraSubject = character
			end
		end
	end

end


tween(cams.Camera1, cams.Camera2, false)
--wait(20)
tween(cams.Camera3, cams.Camera4, false)
--wait(20)
tween(cams.Camera5, cams.Camera6, false)
--wait(20)
tween(cams.Camera7, cams.Camera8, false)
--wait(20)
tween(cams.Camera9, cams.Camera10, true)
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	if tween then
		tween:Stop()
	end
	camera.CameraType = Enum.CameraType.Custom
	local character = workspace:FindFirstChild(player.Name)
	if character then
		camera.CameraSubject = character
	end
	script.Parent.Parent.Parent.Enabled = false
	forcestop = true
end)

Oh yeah, and make sure to merge these scripts into two so the tween variable can be accessed.

That’s a problem. The camera script is in StarterPlayerScripts, and the other one is in StarterGui. Would merging them cause any issues?

I mean you can move the one in StarterPlayerScripts to StarterGui, I think it wouldn’t hurt to do that.

Alright, I’ll try to merge them.