Hey everyone!
First off, Happy Holidays!
Second, I was trying to make a system where when a player holds down "W", their camera slowly increases. I was hoping to get a kind of loop style where if the player holds down W, then it repeats a code telling the camera to move up by 0.01 studs. I honestly had no clue how to do this. Here is my script right now. It's a bit of a mess.
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(inputObject,gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.W then
print"e"
local cam = build.TowerView.CameraPosition
if cam.Position.Y <= build.TowerView.Max.Position.Y then
cam.CFrame = CFrame.new(cam.Position.X,cam.Position.Y+0.01,cam.Position.Z) * CFrame.Angles(math.rad(rot.X),math.rad(rot.Y),math.rad(rot.Z))
game:GetService("Workspace").CurrentCamera.CFrame = CFrame.new(cam.Position)* CFrame.Angles(math.rad(rot.X),math.rad(rot.Y),math.rad(rot.Z))
wait()
end
wait()
end
end)
If you could also suggest ways to clean it up, that would be great!
Thanks!

1 comment
Also I do know that holding down a key will only perform the action once, I would just like to know how I could make it run continuously while the player is holding down a key.