Locked camera in one place

When I play test, the camera is locked in one position with not changing CFrame. This happened after I tried to make a script that changes the camera after interacting with ProximityPrompt using RemoteEvents. I disabled the code but the camera is still not in it’s place.

Also here are the codes, if needed:

The first code that trrigers the event:

local ProximityPrompt = script.Parent
local RemoteEvent = ReplicatedStorage:WaitForChild("CameraEvent") -- Replace with your RemoteEvent name

-- Connect to the ProximityPrompt's Triggered event
ProximityPrompt.Triggered:Connect(function(player)
	-- Fire the RemoteEvent when the player interacts with the prompt
	RemoteEvent:FireServer(player)
end)

The second code that changes the camera (currently disabled):

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera


game.ReplicatedStorage.CameraEvent.OnClientEvent:Connect(function()
	repeat wait()
		Camera.CameraType = Enum.CameraType.Scriptable
	until Camera.CameraType == Enum.CameraType.Scriptable
	Camera.CFrame = CFrame.new(39.73, 5.702, -232.834) * CFrame.Angles(44.25, math.rad(180), 0)
end)

I’m new to scripting so I don’t know what’s happening to the camera and after my research about the camera settings everything seems fine. Also here are the settings if I missed anything.

The camera Properties:

In studio:


In game:

StarterPlayer Properties:

In studio:


In game:

Again thanks, maybe that’s stupid question, but I wasn’t able to solve it on my own. Also if this information is not enough I can give you more or just add you into the project. There is not into it, I use it to try make a game while learning some new things. :smile:

Your firing the event to the server rather than the client, replace it with :FireClient()

2 Likes

Alright I changed it but the issue with the camera is still there.

What @JAcoboiskaka1121 said is correct, but I also spot two more issues:

This loop is completely redundant, as it’s essentially doing this once:

wait() -- By the way, you should stop using wait and use task.wait instead, it's much more optimized
Camera.CameraType = Enum.CameraType.Scriptable

The second issue is that you aren’t setting the camera’s CameraType back to Custom after the cutscene has finished, which is most likely why it’s stuck in the same position

2 Likes

Turn on your script again, and apply the changes @JohhnyLegoKing had mentioned.

2 Likes

So that’s what I made but it’s still not working. What I did wrong?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local ExitButton = game.StarterGui.LapTopGUI.Exit

Camera.CameraType = Enum.CameraType.Custom


game.ReplicatedStorage.CameraEvent.OnClientEvent:Connect(function()
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = workspace.CameraPart.CFrame
end)

ExitButton.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
end)

Out of curiosity, are you firing the CameraEvent in a loop (especially one that’s running per frame) somewhere else? You’ll constantly overwrite the camera’s position, which would essentially lock the camera, if you do that

I’m not firing it even once because to trigger the event the player needs to interact with ProximityPrompt but the problems is that the camera issue is happening after joining. I checked it by printing.

1 Like

If you want I can add you to the game so you can check it by yourself.

1 Like

Does your camera lock in a new baseplate? If it does, then the issue could be happening due to a plugin you might’ve installed

If it only locks when playing this specific game, then the cause of the problem lies in a different script, at least assuming that the code you provided is in full

No that’s the only game with this issue and I shared you the full code. About the scripts I was searching a lot but I ended up not finding.

I’ve just thought of something important: If the LocalScript is named CameraScript and it’s in StarterPlayerScripts, then the issue is that it’s replacing the default camera script, so you’ll need to rename it to something different to fix the issue

1 Like

No way, that was it! XD Thanks a lot, that was strange issue!

1 Like

It’s the way that Roblox allows you implement custom camera scripts, so that the default script doesn’t interfere with it

You should also avoid naming a LocalScript that’s in StarterPlayerScripts to ControlScript, unless you want to write custom controls for the player’s character

There’s also a similar situation in StarterCharacterScripts, if you:

  • Add a server Script named Health
  • Add a LocalScript named Animate
  • Add a LocalScript named Sound

They’ll replace the default ones :slight_smile::+1:

1 Like

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