Hi, I’m very puzzled. So I’m trying to make a ‘build-mode’ camera, so when I hold down MouseButton2 and move it around, the camera moves too! Just like in normal ‘custom’ camera mode. But I have the camera in scriptable mode obviously and need to replicate that same movement when you hold down MouseButton2 down.
Cheers,
What exactly are you trying to achieve?
Like bloxburg’s buildmode camera. Where when you hold down mousebutton2 and move the mouse from side to side, the camera does the same and moves side to side depending on what your mouse is doing.
Bloxburg uses w,a,s,d keys (character limit)
I’m talking about the mouse, if you have bloxburg, go into buildmode, hold down MouseButton2 and move the mouse around, tell me what the camera does. It pans around.
Oh you mean like when the mouse is pointed to the left or right?
if you mean by that il try finding a solution
well, yes. but if you move the mouse slow the camera will pan slowly and if you move the mouse fast then it’ll move faster to what ever direction it moves to.
Okay give me 20 minutes (character limit)
Just clarifying, you don’t want the mouse to be along the mouse itself, you want the camera to be draggable using MouseButton2. Correct?
exactly, yes, camera to be draggable using the mouse
Here’s the script localscript in starterplayerscripts btw
also there needs to be a part in workspace with the orientation set as (-90,0,0)
and anchor it i spent 40 minutes making this would be helpful if you gave me solution
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local plr= game.Players.LocalPlayer
local char = game.Workspace:WaitForChild(plr.Name)
local Cam = game.Workspace.CurrentCamera
Cam.CameraType = "Scriptable"
Cam.CFrame = CFrame.new(0,0,0)
Cam.CFrame = game.Workspace.CamPlace.CFrame
local W,A,S,D,NotMoving = false,false,false,false,true
local function KeepMoving()
repeat
if W then
Cam.CFrame = Cam.CFrame + (Cam.CFrame.UpVector * 0.4)
end
if S then
Cam.CFrame = Cam.CFrame + (Cam.CFrame.UpVector * -0.4)
end
if A then
Cam.CFrame = Cam.CFrame + (Cam.CFrame.RightVector * -0.4)
end
if D then
Cam.CFrame = Cam.CFrame + (Cam.CFrame.RightVector * 0.4)
end
RunService.RenderStepped:Wait()
until NotMoving
end
local function MoveBegan(actionName,inputState,input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
W = true
NotMoving= false
end
if UserInputService:IsKeyDown(Enum.KeyCode.A) then
A = true
NotMoving= false
end
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
S = true
NotMoving= false
end
if UserInputService:IsKeyDown(Enum.KeyCode.D) then
D = true
NotMoving= false
end
end
if W and not S and not D and not A then
KeepMoving()
elseif not W and not S and not D and A then
KeepMoving()
elseif not W and not S and not D and A then
KeepMoving()
elseif not W and not S and not D and A then
KeepMoving()
end
end
local function MoveEnded(input, gpe)
if input.KeyCode == Enum.KeyCode.W then
W = false
elseif input.KeyCode == Enum.KeyCode.S then
S = false
elseif input.KeyCode == Enum.KeyCode.D then
D = false
elseif input.KeyCode == Enum.KeyCode.A then
A = false
end
end
if not W and not S and not D and not A then
NotMoving = true
else
NotMoving = false
end
game:GetService("ContextActionService"):BindAction("MoveCam" , MoveBegan, false,Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D)
UserInputService.InputEnded:Connect(MoveEnded)
Hey, uhm, not what I was looking for, but I haven’t done that part yet and so you’ve helped me with that. Thankyou so much. I’ll definitely be using this code. I was looking for a script that allowed the player to drag the camera using mousebutton2 though.
Sorry i thought you meant using w a s d keys but i can edit it to make it draggable give me a second
StarterPlayerScripts - Localscript
Double click with right mouse and hold the second click
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local Sensitivity = .5
local LastClick = tick()
local Pan = false
Mouse.Button2Down:Connect(function()
if not LastClick then LastClick = tick() return end
local t = (tick() - LastClick)
if t > 0 and t < .5 then
if not Pan then
Pan = true
Camera.CameraType = Enum.CameraType.Scriptable
end
end
LastClick = tick()
end)
Mouse.Button2Up:Connect(function()
Pan = false
Camera.CameraType = Enum.CameraType.Custom
end)
UIS.InputChanged:Connect(function(InputObject)
if InputObject.UserInputType == Enum.UserInputType.MouseMovement then
if Pan then
Camera.CFrame = Camera.CFrame + Camera.CFrame.RightVector*InputObject.Delta.X*Sensitivity - Camera.CFrame.UpVector*InputObject.Delta.Y*Sensitivity
end
end
end)
while wait() do
if Pan then
if UIS:IsKeyDown(Enum.KeyCode.W) then
Camera.CFrame = Camera.CFrame + (Camera.CFrame.LookVector*Sensitivity)
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
Camera.CFrame = Camera.CFrame - (Camera.CFrame.LookVector*Sensitivity)
end
end
end
works while Pan is true, I just used double click to change pan for testing
if you want it always to pan just use this part and set Pan to true
UIS.InputChanged:Connect(function(InputObject)
if InputObject.UserInputType == Enum.UserInputType.MouseMovement then
if Pan then
Camera.CFrame = Camera.CFrame + Camera.CFrame.RightVector*InputObject.Delta.X*Sensitivity - Camera.CFrame.UpVector*InputObject.Delta.Y*Sensitivity
end
end
end)
While i work on making it mousebutton 2 you can use this script for bettter camera movement
LocalScript in starterGUI:
local cam = workspace.CurrentCamera
local camPart = workspace["CamPlace"]
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
repeat
wait()
cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable
local maxTilt = 10
game:GetService("RunService").RenderStepped:Connect(function()
cam.CFrame = camPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
Nevermind it would be buggy (character limit)
I can’t work on the script right now im busy but il get back to you tomorrow
ok, thankyou for your help today.
Testing your method rn, it doesn’t seem to work. Note I am setting the camera to scriptable
Nevermind guys, found out how to do it,