Camera type changing but not actually

game.ReplicatedStorage.RemoteEvents.BlackoutEvent.OnClientEvent:Connect(function(GoingIntoRoom , CameraType)
	local randomangle = math.random(-8,8) * 45
	local TweenService = game:GetService("TweenService")
	local PartProperties = {BackgroundTransparency = 0}
	local TweenInfov = TweenInfo.new(
		0.32,
		Enum.EasingStyle.Linear,--EasingStyle
		Enum.EasingDirection.Out,--Easing direction
		0,--times to repeat
		false,--goes in reverse
		0--delay
	)

	local Tween = TweenService:Create(script.Parent,TweenInfov,{BackgroundTransparency = 0})
	Tween:Play()
	Tween.Completed:Wait()
	if GoingIntoRoom == true then
		game.Lighting.Atmosphere.Haze = 10
	else
		game.Lighting.Atmosphere.Haze = 0
	end
	print(CameraType)
	game.Workspace.CurrentCamera.CameraType = Enum.CameraType[CameraType]
	local Tween = TweenService:Create(script.Parent,TweenInfov,{BackgroundTransparency = 1})
	Tween:Play()
end)

I have a local script that changes the camera type, the problem is that despite it actually changing the camera type on workspace.CurrentCamera, the camera doesn’t change.

Can we see the script? It seems you’ve only posted the example code block

2 Likes

Oops, didn’t notice. Ok im going to edit the post.

Should it happen for all players?

1 Like

Ok, there it is, CameraType is a string value provided by another script, and it does print out correctly.

No, another script triggers the remote event on a specific client.

This might be your reason why, could you try changing it to

    workspce.CurrentCamera.CameraType = CameraType

Since it’s a String Value being passed on, I believe this should work

1 Like

I dont think so, because the value does change properly, its just that the camera doesn´t stay in one position if the value of the string is “fixed”
I do have another script though, so it might be doing something

--Get service needed for events used in this script
local RunService = game:GetService("RunService")	

-- Variables for the camera and player
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
-- Constant variable used to set the camera’s offset from the player
local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
print(CAMERA_OFFSET)
camera.CameraType = Enum.CameraType.Scriptable

local function onRenderStep()
	-- Check the player's character has spawned
	if player.Character then
		local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
		local playerPosition = player.Character.HumanoidRootPart.Position
		local cameraPosition = playerPosition + CAMERA_OFFSET

		-- make the camera follow the player
		camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
	end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

It never hurts to try

Your other script seems to work fine, there isn’t really anything that’s messing with the CameraType property

1 Like

You´re right, im going to try it then.

Ok I tried it, it worked just the same, but the camera still acts as if its being scripted, Maybe it’s because of the :BindToRenderStep that causes the camera to stil behave as if it was scriptable type.

Also I just realised that copying and pasting my code somewhere else really helps me for some reason :man_shrugging:

Hm, maybe just put the BindAction() function out to see if it makes any difference? I don’t think that’d be the case, another instance that I see is that you didn’t really change the CurrentCamera’s CFrame to a certain location on the OnClientEvent?

Yup, didn´t seem to change despite that.

The camera broke now??!!! I disabled the camera script and its stuck looking at 0,0,0

Probably cause it’s not rendering in relevance to the RenderStepped event, since you still set it the CameraType to Scriptable in your other script

1 Like

The other one isn’t triggered at that moment.

Yes I’m aware

Just set that to Custom for the time being, then fire your OnClientEvent to see if anything changes

1 Like

I set it to custom yet the camera is still being scripted???!!!

Did you forget to disable your onRenderStep function

The camera just points to 0,0,0.
I thought that the camera could only be scripted when it was in scriptable mode
P A I N