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.
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.
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.
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
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.
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
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
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: