Hi! For some reason, my camera doesn’t pan when I hold r click in game. The camera is set to custom and there’s really no code that changes anything about the camera (besides FOV). Does anyone know what might be the problem? (Side Note: I do change the mouse between default and locked center if that is worth anything)
I’ve had this issue before when I’ve had studio open for a while. Try deleting the camera object in workspace.
You’ll have to reset all of the properties yourself (if you changed any), but that usually fixes it for me.
This still didn’t change anything. I still can’t pan.
Does this only happen in one experience or everywhere?
Like if you made a new baseplate, does it still not let you pan your camera?
Edit: Also when you say “On Roblox” do you mean on the roblox client or in studio testing?
Both don’t work. I know sometimes studio has some strange bugs. I am going test it on a new baseplate.
I am also unable to pan in another baseplate. I will be sending over the code shortly.
Heres the code:
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum.AutoRotate = false
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local head = char:WaitForChild("Head")
local cursor = false
local keybinds = {
["ToggleCursor"] = Enum.KeyCode.LeftControl,
}
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == keybinds["ToggleCursor"] then
cursor = not cursor
end
end)
rs.Heartbeat:Connect(function()
if (cursor and (camera.CFrame.Position-head.Position).Magnitude > 0.1) or player:GetAttribute("Cursor") then
uis.MouseBehavior = Enum.MouseBehavior.Default
else
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
end
uis.MouseIconEnabled = cursor or player:GetAttribute("Cursor")
end)
Oh this is completely different from what I thought it was.
Now i’m confused as to what you are trying to achieve with this, you can already pan around just by moving your mouse, and you don’t have to hold right click.
Is there some other behavior you want?
Basically, I want there to be different modes you can set your camera to. Lock Center, Shift Lock, and Default.
Edit: Found the bug. Basically whenever you pan your camera, roblox automatically sets the Mouse to LockCurrentPosition (or whatever it is called).
You probably shouldn’t put that in Heartbeat, I’d only change the Mouse’s behavior whenever you click LeftControl.
Sorry for not understanding what the problem was earlier though. (I misread the keybind as left-shift and not left-control and it was putting me into shift lock).
I just ended up putting an if statement within the heartbeat.
- Check for any other code that might be affecting the camera: Make sure that there are no other scripts in your game that might be affecting the camera. This includes any scripts that might be running on the character or on any other parts of the game.
- Check for any disabled camera controls: Double-check your camera settings in the Workspace and make sure that all of the camera controls that you want to use are enabled. This includes the “AllowCameraRotation” setting, which should be enabled if you want to use the right mouse button to pan the camera.
- Check for any conflicts with other input: Make sure that there are no other input bindings that conflict with the right mouse button. For example, if you have a script that uses the right mouse button for some other purpose, this could interfere with the camera controls.
- Check for any issues with the mouse settings: It’s possible that there might be an issue with the way the mouse is being handled in your game. Make sure that the mouse is being set up correctly, and that there are no issues with the “MouseLockOption” property.
- Test with a new project: If you’re still having issues, try creating a new, simple project and see if the camera controls work correctly there. This can help you determine whether the issue is with your code or with something else in your game.
I already fixed it, it is because when you pan roblox sets the mousebehavior to lock at it’s current position, but I continuously set it to default, nullifying the effect.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.