Ive got a script which moves a brick left and right and forward and backwards. When I hold "J" it smoothly continues right, same when i press "G" it smoothly goes left. "Y" and "H" doesnt move forward and backward smoothly. Im not sure why, also I have no errors. The functions are located at the bottom
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local y,g,h,j = 0,0,0,0 Mouse.KeyDown:connect(function(Key) print("cheese") if Key == "j" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(1,0,0) j = 1 keyholdJ() elseif Key == "g" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(-1,0,0) g = 1 keyholdG() elseif Key == "y" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,-1) h = 1 keyholdY() elseif Key == "h" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,1) y = 1 keyholdH() end end) Mouse.KeyUp:connect(function(Key) print("cheese") if Key == "j" then j = 0 elseif Key == "g" then g = 0 elseif Key == "y" then h = 0 elseif Key == "h" then y = 0 end end) --functions of holding down function keyholdJ() while j == 1 do game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(1,0,0) wait(0.01) end end function keyholdG() while g == 1 do game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(-1,0,0) wait(0.01) end end function keyholdH() while h == 1 do game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,-1) wait(0.01) end end function keyholdY() while y == 1 do game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,1) wait(0.01) end end
You mixed up Y and H.
elseif Key == "y" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,-1) y = 1 keyholdY() elseif Key == "h" then game.Workspace.CameraBlock.Position = game.Workspace.CameraBlock.Position + Vector3.new(0,0,1) h = 1 keyholdH() end