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

Setting CameraType to Custom does not reset CFrame nor focus on player? [SOLVED]

I'm sorry for having the last post not make sense, this might help more because I've found the issue.

For some reason, when I try to set workspace.CurrentCamera.CameraType to Enum.CameraType.Custom it doesn't seem to reset the camera position to the player. It just stays at the same position as before. Also, setting the CameraSubject to the players Humanoid also does nothing. Please, someone help I'm getting tired of this not working. Here is my LOCALSCRIPT.

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

function CameraMove(pos1, 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 = pos1
	}
	local tween = TweenService:Create(camera, info, posnx)
	camera.CameraType = Enum.CameraType.Scriptable
	tween:Play()
end

player.CharacterAdded:Wait()
CameraMove(workspace.Camera1.CFrame, true)

game.ReplicatedStorage.Events.BindableEvents.PlayerPressedPlay.Event:Connect(function()
	camera.CameraType = Enum.CameraType.Custom
end)

2 answers

You need to do both, camera type to custom and subject to humanoid. Also you need to make sure the humanoid reference is valid (player may have respawned).

game.ReplicatedStorage.Events.BindableEvents.PlayerPressedPlay.Event:Connect(function()
	print("If you can see this, it means your event is firing properly")
	camera.CameraType = Enum.CameraType.Custom
	local newChar = player.Character or player.CharacterAdded:Wait()
	camera.CameraSubject = newChar:WaitForChild("Humanoid")
end)

It goes without saying, that you should check if your event is firing (I added a print).

Edit: I just noticed you are using a BindableEvent and not RemoteEvent. Local bindable events should not be in the ReplicatedStorage, as they do not need to be replicated to server. You should keep them locally, for example in the StarterPack.

3 comments

0

Hey! thanks for responding, although Im starting to get worried that this isn't working. Even this script just stays at the same CFrame. I don't understand how or why the camera just doesn't want to change!

0

Everything is working, even the print! the cframe just DOESNT change!

0

I really hope that im able to find the issue

I FINALLY FIXED IT! Sorry for the inconvenience, alas it was a STUDIO bug. Delete your script and ctrl c + ctrl v your script into the new one. Hope this helps.

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