I want a camera to move smoothly left right forwards and backwards, so i made a simple script. However, when i press the button W it just doesnt do anything - i have tried changing its rotation and its focus instead, but nothing has happened! Here is the script:
spawn(function()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
end)
local camera = workspace.Camera
local camerapos = camera.CFrame.Position
game.UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.W then
print("moved")
camerapos = camerapos + Vector3.new(10, 0 ,0)
end
end)
Also, whenever i join, the camera has a 50/50 chance of being custom or scriptable, when i want it to be scriptable. Annoying!
Thank you.
As for camera game scripts do set its behavior so you should do:
local camera:Camera = workspace.CurrentCamera or workspace:WaitForChild("Camera")
camera = CameraType = Enum.CameraType.Scriptable
repeat
RunService.Heartbeat:Wait()
camera = CameraType = Enum.CameraType.Scriptable
until camera.CameraType==Enum.CameraType.Scriptable
For movement just do
--DECLEAR OUTSIDE OF FUNCTION
local forward = CFrame.new(10,0,0) --you maybe need to shift arguments a little
---
--code here
camera.CFrame*=forward
Your camera game scripts part i dont understand at all. I put it in and half the lines had errors on it so (i think) i fixed it and it doesnt do anything. Your movement part is just the same thing and doesnt work
I didn’t understand your reply.
I understand that English is not your first language likely (just like mine) but please try forming sentance properly for it to be readable for other speakers
local RunService = game:GetService("RunService")
local camera:Camera = workspace.CurrentCamera or workspace:WaitForChild("Camera")::Camera
camera.CameraType = Enum.CameraType.Scriptable
camera:GetPropertyChangedSignal("CameraType"):Wait()
camera.CameraType = Enum.CameraType.Scriptable
local forward = CFrame.new(0,0,-10)
game.UserInputService.InputBegan:Connect(function(input:InputObject, gameProcessedEvent:boolean):()
if input.KeyCode == Enum.KeyCode.W then
print("moved")
camera.CFrame*=forward
end
end)