Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Camera Script For Over View Will Not Work Right, Will Not Move Camera With CameraPart??

Asked by
LuaDLL 253 Moderation Voter
6 years ago

Script is inside ServerScriptService

local CameraPart = game.Workspace.CamPart
local UIS = game:GetService("UserInputService")

game.Players.PlayerAdded:Connect(function(plr)
    game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Attach
    game.Workspace.CurrentCamera.CameraSubject = CameraPart
end)

UIS.InputBegan:Connect(function(key,gpe)
    if key.KeyCode == Enum.KeyCode.A and not gpe then
        CameraPart.CFrame = CameraPart.CFrame + Vector3.new(-0.5,0,0)
    elseif key.KeyCode == Enum.KeyCode.D and not gpe then
        CameraPart.CFrame = CameraPart.CFrame + Vector3.new(0.5,0,0)
    end
end)

Does not print any errors

0
you cant move the camera without the cameratype being scriptable PolyyDev 214 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hello, use this script, it is made by ultraw and modified by me, press q and e to change camera zoom, press wasd or arrow keys to move camera, and press i and o to zoom up and down here is the script:


cameraAngle = 30 studs = 700 StudsY = 395 wait(.5) a = false b = false local player = game.Players.LocalPlayer local uIP = game:GetService("UserInputService") local cam = game.Workspace.CurrentCamera local debounce = false local loc = nil local q local rs local input local output local die function addInput(inputObject,gPE) if not gPE then if inputObject.KeyCode == Enum.KeyCode.Up then movement = movement + Vector3.new(0,0,-5) elseif inputObject.KeyCode == Enum.KeyCode.Left then movement = movement + Vector3.new(-5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.Down then movement = movement + Vector3.new(0,0,5) elseif inputObject.KeyCode == Enum.KeyCode.Right then movement = movement + Vector3.new(5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.O then movement = movement + Vector3.new(0,3,0) elseif inputObject.KeyCode == Enum.KeyCode.I then movement = movement + Vector3.new(0,-3,0) elseif inputObject.KeyCode == Enum.KeyCode.Q then repeat b=false cameraAngle = cameraAngle + 1 if cameraAngle > 80 then b = true end wait() until b == true elseif inputObject.KeyCode == Enum.KeyCode.E then repeat a=false if cameraAngle < 10 then a = true end cameraAngle = cameraAngle - 1 wait() until a == true elseif inputObject.KeyCode == Enum.KeyCode.W then movement = movement + Vector3.new(0,0,-5) elseif inputObject.KeyCode == Enum.KeyCode.A then movement = movement + Vector3.new(-5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.S then movement = movement + Vector3.new(0,0,5) elseif inputObject.KeyCode == Enum.KeyCode.D then movement = movement + Vector3.new(5,0,0) end end end function endInput(inputObject,gPE) if not gPE then if inputObject.KeyCode == Enum.KeyCode.Up then movement = movement + Vector3.new(0,0,5) elseif inputObject.KeyCode == Enum.KeyCode.Left then movement = movement + Vector3.new(5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.Down then movement = movement + Vector3.new(0,0,-5) elseif inputObject.KeyCode == Enum.KeyCode.Right then movement = movement + Vector3.new(-5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.W then movement = movement + Vector3.new(0,0,5) elseif inputObject.KeyCode == Enum.KeyCode.A then movement = movement + Vector3.new(5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.S then movement = movement + Vector3.new(0,0,-5) elseif inputObject.KeyCode == Enum.KeyCode.D then movement = movement + Vector3.new(-5,0,0) elseif inputObject.KeyCode == Enum.KeyCode.O then movement = movement + Vector3.new(0,-3,0) elseif inputObject.KeyCode == Enum.KeyCode.I then movement = movement + Vector3.new(0,3,0) elseif inputObject.KeyCode == Enum.KeyCode.Q then repeat b=true cameraAngle = cameraAngle -1 wait() until b == true elseif inputObject.KeyCode == Enum.KeyCode.E then repeat a=true cameraAngle = cameraAngle +1 wait() until a == true end end end function render() local m = studs local b = StudsY local XA =(ovr.X+movement.X) local XB = (ovr.Z+movement.Z) local XC = (ovr.Y+movement.Y) local mX = movement.X local mZ = movement.Z local mY = movement.Y if not(XA<m and XA>-m) then mX=0 end if not(XB<m and XB>-m) then mZ=0 end if not(XC<b and XC>-b) then mY=0 end local rV = Vector3.new(mX,mY,mZ) ovr = ovr + rV loc = loc * CFrame.new(rV) cam.CoordinateFrame = loc * CFrame.Angles(math.rad(-cameraAngle),0,0) end function setCam(block) ovr = Vector3.new(0,0,0) loc = block.CFrame cam.CameraType = Enum.CameraType.Scriptable movement = Vector3.new(0,0,0) input = uIP.InputBegan:connect(addInput) output = uIP.InputEnded:connect(endInput) rs = game:GetService("RunService").--[[Render????]]Stepped:connect(render) if uIP:IsKeyDown(Enum.KeyCode.Up) then movement = movement + Vector3.new(0,0,-1) end if uIP:IsKeyDown(Enum.KeyCode.Left) then movement = movement + Vector3.new(-1,0,0) end if uIP:IsKeyDown(Enum.KeyCode.Down) then movement = movement + Vector3.new(0,0,1) end if uIP:IsKeyDown(Enum.KeyCode.Right) then movement = movement + Vector3.new(1,0,0) end if uIP:IsKeyDown(Enum.KeyCode.E) then repeat cameraAngle = cameraAngle -1 wait() until a == true end if uIP:IsKeyDown(Enum.KeyCode.Q) then repeat cameraAngle = cameraAngle +1 wait() until b == true end end function quit() debounce = false if rs then rs:disconnect() end if input then input:disconnect() end if output then output:disconnect() end if q then q:disconnect() end local char = player.Character if char then cam.CameraSubject = char.Humanoid end end function start(block,character) cam.CameraType = Enum.CameraType.Scriptable setCam(block) end repeat wait() until player.Character and player.Character.Parent start(workspace.CameraPart,player.Character)

localscript in StarterPlayerScripts

Ad

Answer this question